Skip to content

Commit 089e3d1

Browse files
committed
Util: Allow an error to be passed to Release.abort()
When generating a new stack trace, don't include Release.abort(). Ref gh-53
1 parent 2aacd83 commit 089e3d1

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ need to install dependencies which are only necessary for the release.
141141

142142
Defines new properties and methods to add to the `Release` object.
143143

144-
#### abort( msg )
144+
#### abort( msg [, error ] )
145145

146-
Aborts the release and prints the message.
146+
Aborts the release and prints the message. If an error object is provided, it is
147+
used for the stack trace, otherwise the current call stack is used.
147148

148149
#### exec( command, options )
149150

lib/util.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,17 @@ Release.define({
2929
process.chdir( directory );
3030
},
3131

32-
abort: function( msg ) {
33-
var error = new Error();
34-
Error.captureStackTrace( error );
32+
abort: function( msg, error ) {
33+
if ( !error ) {
34+
error = new Error( msg );
35+
Error.captureStackTrace( error, Release.abort );
36+
}
37+
3538
console.log( msg.red );
3639
console.log( "Aborting.".red );
40+
console.log();
3741
console.log( error.stack );
42+
3843
process.exit( 1 );
3944
},
4045

0 commit comments

Comments
 (0)