mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 16:30:11 +00:00
Support --assert option for validate command.
Cause HMR to return an error code if validation fails and the --assert option is present.
This commit is contained in:
parent
f61deda4e8
commit
2d20077c08
@ -20,8 +20,7 @@ Error-handling routines for HackMyResume.
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
An amorphous blob of error handling code for HackMyResume. Have an error?
|
An amorphous blob of error handling code for HackMyResume.
|
||||||
Stick it here. We don't mind.
|
|
||||||
@class ErrorHandler
|
@class ErrorHandler
|
||||||
*/
|
*/
|
||||||
var ErrorHandler = module.exports = {
|
var ErrorHandler = module.exports = {
|
||||||
@ -37,8 +36,10 @@ Error-handling routines for HackMyResume.
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if( ex.fluenterror ){
|
if( ex.fluenterror ){
|
||||||
switch( ex.fluenterror ) { // TODO: Remove magic numbers
|
|
||||||
|
switch( ex.fluenterror ) {
|
||||||
|
|
||||||
case HACKMYSTATUS.themeNotFound:
|
case HACKMYSTATUS.themeNotFound:
|
||||||
msg = "The specified theme couldn't be found: " + ex.data;
|
msg = "The specified theme couldn't be found: " + ex.data;
|
||||||
@ -89,6 +90,9 @@ Error-handling routines for HackMyResume.
|
|||||||
'installed and accessible from your path.');
|
'installed and accessible from your path.');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HACKMYSTATUS.invalid:
|
||||||
|
msg = chalk.red.bold('ERROR: Validation failed and the --assert option was specified.');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
exitCode = ex.fluenterror;
|
exitCode = ex.fluenterror;
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@ Status codes for HackMyResume.
|
|||||||
inputOutputParity: 7,
|
inputOutputParity: 7,
|
||||||
createNameMissing: 8,
|
createNameMissing: 8,
|
||||||
wkhtmltopdf: 9,
|
wkhtmltopdf: 9,
|
||||||
missingPackageJSON: 10
|
missingPackageJSON: 10,
|
||||||
|
invalid: 11
|
||||||
};
|
};
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
@ -67,6 +67,7 @@ function main() {
|
|||||||
program
|
program
|
||||||
.command('validate')
|
.command('validate')
|
||||||
.arguments('<sources...>')
|
.arguments('<sources...>')
|
||||||
|
.option('-a --assert', 'Treat validation warnings as errors', false)
|
||||||
.description('Validate a resume in FRESH or JSON RESUME format.')
|
.description('Validate a resume in FRESH or JSON RESUME format.')
|
||||||
.action(function(sources) {
|
.action(function(sources) {
|
||||||
execVerb.call( this, sources, [], this.opts(), logMsg);
|
execVerb.call( this, sources, [], this.opts(), logMsg);
|
||||||
@ -101,7 +102,7 @@ function main() {
|
|||||||
.option('-n --no-prettify', 'Disable HTML prettification', true)
|
.option('-n --no-prettify', 'Disable HTML prettification', true)
|
||||||
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
|
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
|
||||||
.option('-p --pdf <engine>', 'PDF generation engine')
|
.option('-p --pdf <engine>', 'PDF generation engine')
|
||||||
.option('--no-tips', 'Disable theme tips and warnings.', false)
|
.option('--no-tips', 'Disable theme tips and warnings.', false)
|
||||||
.description('Generate resume to multiple formats')
|
.description('Generate resume to multiple formats')
|
||||||
.action(function( sources, targets, options ) {
|
.action(function( sources, targets, options ) {
|
||||||
var x = splitSrcDest.call( this );
|
var x = splitSrcDest.call( this );
|
||||||
|
@ -10,6 +10,7 @@ Implementation of the 'validate' verb for HackMyResume.
|
|||||||
var ResumeFactory = require('../core/resume-factory');
|
var ResumeFactory = require('../core/resume-factory');
|
||||||
var SyntaxErrorEx = require('../utils/syntax-error-ex');
|
var SyntaxErrorEx = require('../utils/syntax-error-ex');
|
||||||
var chalk = require('chalk');
|
var chalk = require('chalk');
|
||||||
|
var HACKMYSTATUS = require('../core/status-codes');
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ Implementation of the 'validate' verb for HackMyResume.
|
|||||||
else {
|
else {
|
||||||
_log(chalk.red.bold('ERROR: ' + ex.toString()));
|
_log(chalk.red.bold('ERROR: ' + ex.toString()));
|
||||||
}
|
}
|
||||||
|
if( opts.assert ) throw { fluenterror: HACKMYSTATUS.invalid };
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +94,10 @@ Implementation of the 'validate' verb for HackMyResume.
|
|||||||
err.message) );
|
err.message) );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if( opts.assert && !isValid ) {
|
||||||
|
throw { fluenterror: HACKMYSTATUS.invalid, shouldExit: true };
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user