App Lifecycle


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

fig.init = (stdin, options) => {
    console.log(stdin)   // "Hello, world"
    console.log(options) // ["parameter", "--flag", "value"]

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.

Last updated