Skip to main content
This project is an incubation project being run inside the Green Software Foundation; as such, we DON’T recommend using it in any critical use case. Incubation projects are experimental, offer no support guarantee, have minimal governance and process, and may be retired at any moment. This project may one day Graduate, in which case this disclaimer will be removed.

How to create an exhaust script

The If framework outputs data in yaml format. Any other output formats require a separate script that takes the yaml output data and processes it. We provide if-csv for outputting data in csv format bundled with IF. For any other format, you need to write an exhaust script. This guide will help you create your own exhaust script.

In this example, we'll create a script that executes the manifest and outputs the data in json format.

const IfJson = async () => {
const { manifest, output } = await parseIfCsvArgs();

if (manifest) {
const { rawManifest } = await load(manifest);
const { children } = rawManifest.tree;

if (!(children?.child || children?.['child-0']).outputs) {
throw new ManifestValidationError(FAILURE_MESSAGE_OUTPUTS);
}

// Add logic to export the executed manifest to `json` format.
}

process.exit(0);
};

IfJson().catch(handleError);

To add this script to your package.json, include the following entry in the scripts section:

"scripts": {
"if-json": "npx ts-node if-json.ts"
}

This setup ensures that your script will execute the manifest and output the data in JSON format.