diff --git a/cli.js b/cli.js index b837502c..f481b095 100755 --- a/cli.js +++ b/cli.js @@ -34,6 +34,12 @@ function printUsageAndExit (isError) { if (args.help) { printUsageAndExit(false) +} else if (args.version) { + if (typeof args.version !== 'boolean') { + console.error('--version does not take an argument. Perhaps you meant --app-version or --electron-version?\n') + } + console.log(common.hostInfo()) + process.exit(0) } else if (!args.dir) { printUsageAndExit(true) } diff --git a/common.js b/common.js index 156751b4..d389ffa1 100644 --- a/common.js +++ b/common.js @@ -1,5 +1,6 @@ 'use strict' +const metadata = require('./package.json') const os = require('os') const path = require('path') const sanitize = require('sanitize-filename') @@ -149,6 +150,11 @@ module.exports = { return pathToNormalize.replace(/\\/g, '/') }, + hostInfo: function hostInfo () { + return `Electron Packager ${metadata.version}\n` + + `Node ${process.version}\n` + + `Host Operating system: ${process.platform} (${process.arch})` + }, info: info, warning: warning } diff --git a/index.js b/index.js index 5b3bd0fc..807900d8 100644 --- a/index.js +++ b/index.js @@ -8,16 +8,13 @@ const fs = require('fs-extra') const getMetadataFromPackageJSON = require('./infer') const hooks = require('./hooks') const ignore = require('./ignore') -const metadata = require('./package.json') const nodeify = require('nodeify') const path = require('path') const pify = require('pify') const targets = require('./targets') function debugHostInfo () { - debug(`Electron Packager ${metadata.version}`) - debug(`Node ${process.version}`) - debug(`Host Operating system: ${process.platform} (${process.arch})`) + debug(common.hostInfo()) } class Packager { diff --git a/usage.txt b/usage.txt index e1c4af16..295ce796 100644 --- a/usage.txt +++ b/usage.txt @@ -1,17 +1,22 @@ Usage: electron-packager [options...] -Required options +Required parameters sourcedir the base directory of the application source Examples: electron-packager ./ electron-packager ./ --all -Optional options +Optional parameters appname the name of the app, if it needs to be different from the "productName" or "name" in the nearest package.json +Options + +version prints the version of Electron Packager and Node, plus the target platform and + arch, for bug reporting purposes, and exits immediately + * All platforms * all equivalent to --platform=all --arch=all