From 2d20077c0879fcee590bd3cf03aea286399f85e4 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Wed, 6 Jan 2016 00:44:34 -0500 Subject: [PATCH] Support --assert option for validate command. Cause HMR to return an error code if validation fails and the --assert option is present. --- src/core/error-handler.js | 10 +++++++--- src/core/status-codes.js | 3 ++- src/index.js | 3 ++- src/verbs/validate.js | 6 ++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/core/error-handler.js b/src/core/error-handler.js index 78a848d..bab6054 100644 --- a/src/core/error-handler.js +++ b/src/core/error-handler.js @@ -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; diff --git a/src/core/status-codes.js b/src/core/status-codes.js index 400467f..f6d1d71 100644 --- a/src/core/status-codes.js +++ b/src/core/status-codes.js @@ -17,7 +17,8 @@ Status codes for HackMyResume. inputOutputParity: 7, createNameMissing: 8, wkhtmltopdf: 9, - missingPackageJSON: 10 + missingPackageJSON: 10, + invalid: 11 }; }()); diff --git a/src/index.js b/src/index.js index 95b8d5c..f593dd4 100644 --- a/src/index.js +++ b/src/index.js @@ -67,6 +67,7 @@ function main() { program .command('validate') .arguments('') + .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