From 984ae95576b8aeaba7d06420945c9a14a926651a Mon Sep 17 00:00:00 2001 From: hacksalot Date: Wed, 20 Jan 2016 21:43:11 -0500 Subject: [PATCH] Cleanup. --- src/cli/out.js | 7 +++---- src/core/event-codes.js | 4 +++- src/verbs/build.js | 8 +------- src/verbs/validate.js | 19 ++++++++++--------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/cli/out.js b/src/cli/out.js index 8300a20..58ff0c5 100644 --- a/src/cli/out.js +++ b/src/cli/out.js @@ -87,8 +87,6 @@ Output routines for HackMyResume. break; case HME.afterTheme: - this.theme = evt.theme; - // this.opts.debug && L( M2C(this.msgs.beforeTheme.msg, 'green'), evt.theme ); break; case HME.beforeMerge: @@ -107,9 +105,10 @@ Output routines for HackMyResume. break; case HME.applyTheme: - var numFormats = Object.keys( this.theme.formats ).length; + this.theme = evt.theme; + var numFormats = Object.keys( evt.theme.formats ).length; L( M2C(this.msgs.applyTheme.msg, 'green'), - this.theme.name.toUpperCase(), + evt.theme.name.toUpperCase(), numFormats, ( numFormats === 1 ? '' : 's') ); break; diff --git a/src/core/event-codes.js b/src/core/event-codes.js index 55cf36f..ab7703d 100644 --- a/src/core/event-codes.js +++ b/src/core/event-codes.js @@ -36,7 +36,9 @@ Event code definitions. beforePeek: 20, afterPeek: 21, beforeInlineConvert: 22, - afterInlineConvert: 23 + afterInlineConvert: 23, + beforeValidate: 24, + afterValidate: 25 }; diff --git a/src/verbs/build.js b/src/verbs/build.js index dbbe1cb..517af0e 100644 --- a/src/verbs/build.js +++ b/src/verbs/build.js @@ -117,7 +117,7 @@ Implementation of the 'build' verb for HackMyResume. // Add freebie formats to the theme addFreebieFormats( theme ); - this.stat( HMEVENT.applyTheme, { r: rez }); + this.stat( HMEVENT.applyTheme, { r: rez, theme: theme }); // Load the resume into a FRESHResume or JRSResume object _rezObj = new (RTYPES[ toFormat ])().parseJSON( rez ); @@ -161,12 +161,6 @@ Implementation of the 'build' verb for HackMyResume. - function handleInternalError( ex ) { - console.log(ex); - } - - - /** Generate a single target resume such as "out/rez.html" or "out/rez.doc". TODO: Refactor. diff --git a/src/verbs/validate.js b/src/verbs/validate.js index 6603d22..814d469 100644 --- a/src/verbs/validate.js +++ b/src/verbs/validate.js @@ -4,8 +4,12 @@ Implementation of the 'validate' verb for HackMyResume. @license MIT. See LICENSE.md for details. */ + + (function() { + + var FS = require('fs'); var ResumeFactory = require('../core/resume-factory'); var SyntaxErrorEx = require('../utils/syntax-error-ex'); @@ -17,6 +21,7 @@ Implementation of the 'validate' verb for HackMyResume. + /** An invokable resume validation command. */ var ValidateVerb = module.exports = Verb.extend({ init: function() { @@ -33,16 +38,12 @@ Implementation of the 'validate' verb for HackMyResume. - /** - Validate 1 to N resumes in either FRESH or JSON Resume format. - */ + /** Validate 1 to N resumes in FRESH or JSON Resume format. */ function validate( sources, unused, opts ) { if( !sources || !sources.length ) throw { fluenterror: HMSTATUS.resumeNotFoundAlt, quit: true }; - var isValid = true; - var validator = require('is-my-json-valid'); var schemas = { fresh: require('fresca'), @@ -82,14 +83,14 @@ Implementation of the 'validate' verb for HackMyResume. } } - catch(exc) { + catch( exc ) { return ret; } - this.stat(HMEVENT.afterValidate, { file: src.file, isValid: isValid, - fmt: fmt.replace('jars', 'JSON Resume'), errors: errors }); + this.stat( HMEVENT.afterValidate, { file: src.file, isValid: ret.isValid, + fmt: fmt.replace( 'jars', 'JSON Resume' ), errors: errors }); - if( opts.assert && !isValid ) { + if( opts.assert && !ret.isValid ) { throw { fluenterror: HMSTATUS.invalid, shouldExit: true }; }