Fig Docs
Search…
App Lifecycle

Initialization

fig.init is the entry point for your app. fig.init is called once the fig.js runtime has loaded and configured the environment. Attempting to run fig commands before fig.init has been called will result in undefined behavior.
$ echo "Hello, world."| fig your-app parameter --flag value
1
fig.init = (stdin, options) => {
2
console.log(stdin) // "Hello, world"
3
console.log(options) // ["parameter", "--flag", "value"]
4
}
Copied!
In this case, stdin would be "Hello, world.". and options will be a list of the CLI flags. If your app is called with nothing piped in, stdin will be an empty string.
fig.init provides your app with any data from stdin that is passed to it as well as any flags/options, it is called with. The array of options can also be accessed with fig.options.
Copy link