Skip to content

Commit

Permalink
Merge pull request #805 from electron-userland/help-to-stdout
Browse files Browse the repository at this point in the history
Send usage text to stdout if --help specified
  • Loading branch information
malept committed Feb 13, 2018
2 parents 197ab5c + 9b99e15 commit 0e9f65d
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions cli.js
Expand Up @@ -18,13 +18,24 @@ var usage = fs.readFileSync(path.join(__dirname, 'usage.txt')).toString()

var args = common.parseCLIArgs(process.argv.slice(2))

if (!args.dir) {
// temporary fix for https://github.com/nodejs/node/issues/6456
if (process.stderr._handle && process.stderr._handle.setBlocking) {
process.stderr._handle.setBlocking(true)
// temporary fix for https://github.com/nodejs/node/issues/6456
var stdioWriters = [process.stdout, process.stderr]
stdioWriters.forEach(function (stdioWriter) {
if (stdioWriter._handle && stdioWriter._handle.setBlocking) {
stdioWriter._handle.setBlocking(true)
}
console.error(usage)
process.exit(1)
})

function printUsageAndExit (isError) {
var print = isError ? console.error : console.log
print(usage)
process.exit(isError ? 1 : 0)
}

if (args.help) {
printUsageAndExit(false)
} else if (!args.dir) {
printUsageAndExit(true)
}

packager(args, function done (err, appPaths) {
Expand Down

0 comments on commit 0e9f65d

Please sign in to comment.