Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send usage text to stdout if --help specified #805

Merged
merged 1 commit into from Feb 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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