Plugins

Run custom scripts on Nimbus lifecycle events.

Plugins are scripts referenced from the hooks object in nimbus.config.json (see Configuration). Nimbus runs them as child processes and passes context as JSON on stdin.

Available hooks

Hook Fires
preSync Before a sync starts.
postSync After a sync completes successfully.
onConflict When conflictStrategy is manual and a conflict is found.
onError When a sync fails.

Example: Slack notification

plugins/notify-slack.js:

const data = JSON.parse(require('fs').readFileSync(0, 'utf8'));

await fetch(process.env.SLACK_WEBHOOK_URL, {
	method: 'POST',
	body: JSON.stringify({ text: `Synced ${data.filesChanged} files to ${data.target}` }),
});

Wire it up:

{ "hooks": { "postSync": "plugins/notify-slack.js" } }

Exit codes

A non-zero exit code from preSync aborts the sync before any upload starts. postSync and onError exit codes are logged but don’t affect the sync result.