docs/toolbox-meta.md
Provides functions for accessing information about the currently running CLI. You can access this on the Gluegun toolbox.
The currently running CLI's source folder.
toolbox.meta.src // "/Users/jh/Code/gluegun"
Retrieves the currently running CLI's version.
toolbox.meta.version() // '1.0.0'
Retrieves the currently running CLI's package.json contents as an object.
toolbox.meta.packageJSON()
// { name: 'gluegun', version: '9.4.2', ... }
Async function that checks NPM to see if there's an update to the currently running CLI.
const newVersion = await toolbox.meta.checkForUpdate()
// false (if none exists)
// '9.4.3' (new version if exists)
if (newVersion) {
toolbox.print.info(`New version available: ${newVersion})`)
}
Retrieves information about all of this CLI's commands. You can use this to display a custom help screen, for example.
const commandInfo = toolbox.meta.commandInfo()
toolbox.print.table(commandInfo)
Executes the given callback when a termination signal is received. These signals are SIGINT, SIGQUIT, SIGTERM, SIGHUP, SIGBREAK. If callback returns a promise, it will wait for promise to resolve before aborting.
toolbox.meta.onAbort((signal) => {
console.log('Received termination signal', signal)
})