-
Notifications
You must be signed in to change notification settings - Fork 799
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
Don't fail on stderr output, but print the output to stderr #110
Changes from 2 commits
8f0623b
82cabab
458da35
6338f32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,17 @@ function outputChangelog (argv, cb) { | |
}) | ||
} | ||
|
||
function handleExecError (err, stderr) { | ||
// If exec returns an error or content in stderr, log it and exit with return code 1 | ||
var errMessage = stderr || (err && err.message) | ||
if (errMessage) { | ||
console.error(chalk.red(errMessage)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should print to
AFAIK chalk should handle coloring the output correctly regardless of the stream it will be printed to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry for my poor knowledge, yellow would be great! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 458da35 |
||
if (err) { | ||
process.exit(1) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Tapppi , i think it would be better to be: if (err) {
console.error(chalk.red(stderr || err.message))
process.exit(1)
} else if(stderr) {
console.warn(chalk.yellow(stderr))
} the prior There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea, changed in 6338f32 |
||
} | ||
} | ||
|
||
function commit (argv, newVersion, cb) { | ||
var msg = 'committing %s' | ||
var args = [argv.infile] | ||
|
@@ -118,14 +129,6 @@ function commit (argv, newVersion, cb) { | |
} | ||
checkpoint(msg, args) | ||
|
||
function handleExecError (err, stderr) { | ||
// If exec returns an error or content in stderr, log it and exit with return code 1 | ||
var errMessage = stderr || (err && err.message) | ||
if (errMessage) { | ||
console.log(chalk.red(errMessage)) | ||
process.exit(1) | ||
} | ||
} | ||
exec('git add package.json ' + argv.infile, function (err, stdout, stderr) { | ||
handleExecError(err, stderr) | ||
exec('git commit ' + verify + (argv.sign ? '-S ' : '') + 'package.json ' + argv.infile + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', function (err, stdout, stderr) { | ||
|
@@ -148,17 +151,11 @@ function tag (newVersion, argv) { | |
} | ||
checkpoint('tagging release %s', [newVersion]) | ||
exec('git tag ' + tagOption + 'v' + newVersion + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', function (err, stdout, stderr) { | ||
handleExecError(err, stderr) | ||
var message = 'git push --follow-tags origin master' | ||
var errMessage = null | ||
if (err) errMessage = err.message | ||
if (stderr) errMessage = stderr | ||
if (pkg.private !== true) message += '; npm publish' | ||
if (errMessage) { | ||
console.log(chalk.red(errMessage)) | ||
process.exit(1) | ||
} else { | ||
checkpoint('Run `%s` to publish', [message], chalk.blue(figures.info)) | ||
} | ||
|
||
checkpoint('Run `%s` to publish', [message], chalk.blue(figures.info)) | ||
}) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we should handle
err
andstderr
differently?the problem is with
stderr
shouldn't terminate the program. But forerr
we keep the same behaviour. No?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I misread your code. It LGTM now.