mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 08:20:11 +00:00
Reconnect process exit codes.
This commit is contained in:
parent
23cd52885b
commit
2f628f8564
@ -16,7 +16,7 @@ Definition of the `main` function.
|
|||||||
, EXTEND = require('extend')
|
, EXTEND = require('extend')
|
||||||
, chalk = require('chalk')
|
, chalk = require('chalk')
|
||||||
, PATH = require('path')
|
, PATH = require('path')
|
||||||
, HACKMYSTATUS = require('../core/status-codes')
|
, HMSTATUS = require('../core/status-codes')
|
||||||
, HME = require('../core/event-codes')
|
, HME = require('../core/event-codes')
|
||||||
, safeLoadJSON = require('../utils/safe-json-loader')
|
, safeLoadJSON = require('../utils/safe-json-loader')
|
||||||
, StringUtils = require('../utils/string.js')
|
, StringUtils = require('../utils/string.js')
|
||||||
@ -150,14 +150,15 @@ Definition of the `main` function.
|
|||||||
|
|
||||||
// Handle invalid verbs here (a bit easier here than in commander.js)...
|
// Handle invalid verbs here (a bit easier here than in commander.js)...
|
||||||
if( o.verb && !HMR.verbs[ o.verb ] && !HMR.alias[ o.verb ] ) {
|
if( o.verb && !HMR.verbs[ o.verb ] && !HMR.alias[ o.verb ] ) {
|
||||||
throw { fluenterror: HACKMYSTATUS.invalidCommand, shouldExit: true,
|
throw { fluenterror: HMSTATUS.invalidCommand, quit: true,
|
||||||
attempted: o.orgVerb };
|
attempted: o.orgVerb };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override the .missingArgument behavior
|
// Override the .missingArgument behavior
|
||||||
Command.prototype.missingArgument = function(name) {
|
Command.prototype.missingArgument = function(name) {
|
||||||
if( this.name() !== 'new' )
|
if( this.name() !== 'new' ) {
|
||||||
throw { fluenterror: HACKMYSTATUS.resumeNotFound };
|
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Override the .helpInformation behavior
|
// Override the .helpInformation behavior
|
||||||
@ -243,7 +244,8 @@ Definition of the `main` function.
|
|||||||
hand.err.apply( hand, arguments );
|
hand.err.apply( hand, arguments );
|
||||||
});
|
});
|
||||||
v.invoke.call( v, src, dst, _opts, log );
|
v.invoke.call( v, src, dst, _opts, log );
|
||||||
|
if( v.errorCode )
|
||||||
|
process.exit(v.errorCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -293,7 +295,7 @@ Definition of the `main` function.
|
|||||||
|
|
||||||
var params = this.parent.args.filter(function(j) { return String.is(j); });
|
var params = this.parent.args.filter(function(j) { return String.is(j); });
|
||||||
if( params.length === 0 )
|
if( params.length === 0 )
|
||||||
throw { fluenterror: HACKMYSTATUS.resumeNotFound };
|
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true };
|
||||||
|
|
||||||
// Find the TO keyword, if any
|
// Find the TO keyword, if any
|
||||||
var splitAt = _.findIndex( params, function(p) {
|
var splitAt = _.findIndex( params, function(p) {
|
||||||
|
@ -42,7 +42,7 @@ Implementation of the 'analyze' verb for HackMyResume.
|
|||||||
*/
|
*/
|
||||||
function analyze( sources, dst, opts ) {
|
function analyze( sources, dst, opts ) {
|
||||||
if( !sources || !sources.length )
|
if( !sources || !sources.length )
|
||||||
throw { fluenterror: HMSTATUS.resumeNotFound };
|
throw { fluenterror: HMSTATUS.resumeNotFound, quit: true };
|
||||||
|
|
||||||
var nlzrs = _loadInspectors();
|
var nlzrs = _loadInspectors();
|
||||||
|
|
||||||
@ -50,7 +50,10 @@ Implementation of the 'analyze' verb for HackMyResume.
|
|||||||
var result = ResumeFactory.loadOne( src, {
|
var result = ResumeFactory.loadOne( src, {
|
||||||
format: 'FRESH', objectify: true
|
format: 'FRESH', objectify: true
|
||||||
}, this);
|
}, this);
|
||||||
result.fluenterror || _analyze.call(this, result, nlzrs, opts );
|
if( result.fluenterror )
|
||||||
|
this.setError( result.fluenterror, result );
|
||||||
|
else
|
||||||
|
_analyze.call(this, result, nlzrs, opts );
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,9 @@ Implementation of the 'build' verb for HackMyResume.
|
|||||||
*/
|
*/
|
||||||
function build( src, dst, opts ) {
|
function build( src, dst, opts ) {
|
||||||
|
|
||||||
if( !src || !src.length ) { this.err( HMSTATUS.resumeNotFound ); }
|
if( !src || !src.length ) {
|
||||||
|
this.err( HMSTATUS.resumeNotFound, { quit: true } );
|
||||||
|
}
|
||||||
|
|
||||||
prep( src, dst, opts );
|
prep( src, dst, opts );
|
||||||
|
|
||||||
|
@ -40,20 +40,20 @@ Implementation of the 'convert' verb for HackMyResume.
|
|||||||
function convert( srcs, dst, opts ) {
|
function convert( srcs, dst, opts ) {
|
||||||
|
|
||||||
// Housekeeping
|
// Housekeeping
|
||||||
if( !srcs || !srcs.length ) { throw { fluenterror: 6 }; }
|
if( !srcs || !srcs.length ) { throw { fluenterror: 6, quit: true }; }
|
||||||
if( !dst || !dst.length ) {
|
if( !dst || !dst.length ) {
|
||||||
if( srcs.length === 1 ) {
|
if( srcs.length === 1 ) {
|
||||||
throw { fluenterror: HMSTATUS.inputOutputParity };
|
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
|
||||||
}
|
}
|
||||||
else if( srcs.length === 2 ) {
|
else if( srcs.length === 2 ) {
|
||||||
dst = dst || []; dst.push( srcs.pop() );
|
dst = dst || []; dst.push( srcs.pop() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw { fluenterror: HMSTATUS.inputOutputParity };
|
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(srcs && dst && srcs.length && dst.length && srcs.length !== dst.length){
|
if(srcs && dst && srcs.length && dst.length && srcs.length !== dst.length){
|
||||||
throw { fluenterror: HMSTATUS.inputOutputParity };
|
throw { fluenterror: HMSTATUS.inputOutputParity, quit: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load source resumes
|
// Load source resumes
|
||||||
|
@ -41,7 +41,8 @@ Implementation of the 'create' verb for HackMyResume.
|
|||||||
*/
|
*/
|
||||||
function create( src, dst, opts ) {
|
function create( src, dst, opts ) {
|
||||||
|
|
||||||
if(!src || !src.length) throw {fluenterror: HMSTATUS.createNameMissing};
|
if( !src || !src.length )
|
||||||
|
throw { fluenterror: HMSTATUS.createNameMissing, quit: true };
|
||||||
|
|
||||||
_.each( src, function( t ) {
|
_.each( src, function( t ) {
|
||||||
var safeFmt = opts.format.toUpperCase();
|
var safeFmt = opts.format.toUpperCase();
|
||||||
|
@ -67,12 +67,11 @@ Implementation of the 'peek' verb for HackMyResume.
|
|||||||
|
|
||||||
// safeLoadJSON can only return a READ error or a PARSE error
|
// safeLoadJSON can only return a READ error or a PARSE error
|
||||||
if( obj.ex ) {
|
if( obj.ex ) {
|
||||||
if( obj.ex.operation === 'parse' )
|
var errCode = obj.ex.operation === 'parse' ? HMSTATUS.parseError : HMSTATUS.readError;
|
||||||
this.err( HMSTATUS.parseError, obj.ex );
|
if( errCode === HMSTATUS.readError )
|
||||||
else {
|
|
||||||
obj.ex.quiet = true;
|
obj.ex.quiet = true;
|
||||||
this.err( HMSTATUS.readError, obj.ex );
|
this.setError( errCode, obj.ex );
|
||||||
}
|
this.err( errCode, obj.ex );
|
||||||
}
|
}
|
||||||
|
|
||||||
}, this);
|
}, this);
|
||||||
|
@ -38,7 +38,9 @@ Implementation of the 'validate' verb for HackMyResume.
|
|||||||
*/
|
*/
|
||||||
function validate( sources, unused, opts ) {
|
function validate( sources, unused, opts ) {
|
||||||
|
|
||||||
if( !sources || !sources.length ) { throw { fluenterror: 6 }; }
|
if( !sources || !sources.length )
|
||||||
|
throw { fluenterror: HMSTATUS.resumeNotFoundAlt, quit: true };
|
||||||
|
|
||||||
var isValid = true;
|
var isValid = true;
|
||||||
|
|
||||||
var validator = require('is-my-json-valid');
|
var validator = require('is-my-json-valid');
|
||||||
@ -61,6 +63,7 @@ Implementation of the 'validate' verb for HackMyResume.
|
|||||||
// If there was an error reading the resume
|
// If there was an error reading the resume
|
||||||
if( src.fluenterror ) {
|
if( src.fluenterror ) {
|
||||||
if( opts.assert ) throw src;
|
if( opts.assert ) throw src;
|
||||||
|
this.setError( src.fluenterror, src );
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +78,19 @@ Definition of the Verb class.
|
|||||||
payload.sub = subEvent;
|
payload.sub = subEvent;
|
||||||
this.fire('status', payload);
|
this.fire('status', payload);
|
||||||
return true;
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Associate error info with the invocation.
|
||||||
|
*/
|
||||||
|
setError: function( code, obj ) {
|
||||||
|
this.errorCode = code;
|
||||||
|
this.errorObj = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
0|
|
0|
|
||||||
4|--help
|
0|--help
|
||||||
4|-h
|
0|-h
|
||||||
4|--debug
|
0|--debug
|
||||||
4|-d
|
0|-d
|
||||||
5|notacommand
|
5|notacommand
|
||||||
3|build
|
3|build
|
||||||
14|build doesnt-exist.json
|
14|build doesnt-exist.json
|
||||||
|
Loading…
Reference in New Issue
Block a user