mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-05 09:56:22 +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?
|
||||
Stick it here. We don't mind.
|
||||
An amorphous blob of error handling code for HackMyResume.
|
||||
@class ErrorHandler
|
||||
*/
|
||||
var ErrorHandler = module.exports = {
|
||||
@ -37,8 +36,10 @@ Error-handling routines for HackMyResume.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( ex.fluenterror ){
|
||||
switch( ex.fluenterror ) { // TODO: Remove magic numbers
|
||||
|
||||
switch( ex.fluenterror ) {
|
||||
|
||||
case HACKMYSTATUS.themeNotFound:
|
||||
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.');
|
||||
break;
|
||||
|
||||
case HACKMYSTATUS.invalid:
|
||||
msg = chalk.red.bold('ERROR: Validation failed and the --assert option was specified.');
|
||||
break;
|
||||
}
|
||||
exitCode = ex.fluenterror;
|
||||
|
||||
|
@ -17,7 +17,8 @@ Status codes for HackMyResume.
|
||||
inputOutputParity: 7,
|
||||
createNameMissing: 8,
|
||||
wkhtmltopdf: 9,
|
||||
missingPackageJSON: 10
|
||||
missingPackageJSON: 10,
|
||||
invalid: 11
|
||||
};
|
||||
|
||||
}());
|
||||
|
@ -67,6 +67,7 @@ function main() {
|
||||
program
|
||||
.command('validate')
|
||||
.arguments('<sources...>')
|
||||
.option('-a --assert', 'Treat validation warnings as errors', false)
|
||||
.description('Validate a resume in FRESH or JSON RESUME format.')
|
||||
.action(function(sources) {
|
||||
execVerb.call( this, sources, [], this.opts(), logMsg);
|
||||
@ -101,7 +102,7 @@ function main() {
|
||||
.option('-n --no-prettify', 'Disable HTML prettification', true)
|
||||
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
|
||||
.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')
|
||||
.action(function( sources, targets, options ) {
|
||||
var x = splitSrcDest.call( this );
|
||||
|
@ -10,6 +10,7 @@ Implementation of the 'validate' verb for HackMyResume.
|
||||
var ResumeFactory = require('../core/resume-factory');
|
||||
var SyntaxErrorEx = require('../utils/syntax-error-ex');
|
||||
var chalk = require('chalk');
|
||||
var HACKMYSTATUS = require('../core/status-codes');
|
||||
|
||||
module.exports =
|
||||
|
||||
@ -55,6 +56,7 @@ Implementation of the 'validate' verb for HackMyResume.
|
||||
else {
|
||||
_log(chalk.red.bold('ERROR: ' + ex.toString()));
|
||||
}
|
||||
if( opts.assert ) throw { fluenterror: HACKMYSTATUS.invalid };
|
||||
return;
|
||||
}
|
||||
|
||||
@ -92,6 +94,10 @@ Implementation of the 'validate' verb for HackMyResume.
|
||||
err.message) );
|
||||
});
|
||||
|
||||
if( opts.assert && !isValid ) {
|
||||
throw { fluenterror: HACKMYSTATUS.invalid, shouldExit: true };
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user