UNPKG

balena-cli

Version:

The official balena Command Line Interface

65 lines (62 loc) 2.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const core_1 = require("@oclif/core"); const lazy_1 = require("../../utils/lazy"); class VersionCmd extends core_1.Command { async run() { const { flags: options } = await this.parse(VersionCmd); const versions = { 'balena-cli': (await Promise.resolve().then(() => require('../../../package.json'))).version, 'Node.js': process.version && process.version.startsWith('v') ? process.version.slice(1) : process.version, }; if (options.json) { console.log(JSON.stringify(versions, null, 4)); } else { if (options.all) { console.log(`balena-cli version "${versions['balena-cli']}"`); console.log(`Node.js version "${versions['Node.js']}"`); } else { console.log(versions['balena-cli']); } } } } VersionCmd.description = (0, lazy_1.stripIndent) ` Display version information for the balena CLI and/or Node.js. Display version information for the balena CLI and/or Node.js. Note that the balena CLI executable installers for Windows and macOS, and the standalone zip packages, ship with a built-in copy of Node.js. In this case, the reported version of Node.js regards this built-in copy, rather than any other \`node\` engine that may also be available on the command prompt. The --json option is recommended when scripting the output of this command, because the JSON format is less likely to change and it better represents data types like lists and empty strings. The 'jq' utility may be helpful in shell scripts (https://stedolan.github.io/jq/manual/). This command can also be invoked with 'balena --version' or 'balena -v'. `; VersionCmd.examples = [ '$ balena version', '$ balena version -a', '$ balena version -j', `$ balena --version`, `$ balena -v`, ]; VersionCmd.offlineCompatible = true; VersionCmd.flags = { all: core_1.Flags.boolean({ default: false, char: 'a', description: 'include version information for additional components (Node.js)', }), json: core_1.Flags.boolean({ default: false, char: 'j', description: 'output version information in JSON format for programmatic use', }), }; exports.default = VersionCmd; //# sourceMappingURL=index.js.map