mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-25 01:40:10 +00:00
Start moving logging out of core.
This commit is contained in:
parent
d77b484e55
commit
732bc9809a
43
src/core/event-codes.js
Normal file
43
src/core/event-codes.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
Event code definitions.
|
||||||
|
@module event-codes.js
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
var val = 0;
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
unknown: 0,
|
||||||
|
unk: 0,
|
||||||
|
|
||||||
|
begin: 1,
|
||||||
|
end: 2,
|
||||||
|
|
||||||
|
beforeRead: 3,
|
||||||
|
afterRead: 4,
|
||||||
|
|
||||||
|
beforeCreate: 5,
|
||||||
|
bc: 5,
|
||||||
|
|
||||||
|
afterCreate: 6,
|
||||||
|
ac: 6,
|
||||||
|
|
||||||
|
beforeTheme: 7,
|
||||||
|
afterTheme: 8,
|
||||||
|
|
||||||
|
beforeMerge: 9,
|
||||||
|
afterMerge: 10,
|
||||||
|
|
||||||
|
beforeGenerate: 11,
|
||||||
|
afterGenerate: 12
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}());
|
@ -23,12 +23,28 @@ Definition of the Verb class.
|
|||||||
*/
|
*/
|
||||||
var Verb = module.exports = Class.extend({
|
var Verb = module.exports = Class.extend({
|
||||||
|
|
||||||
init: function() {
|
init: function( moniker ) {
|
||||||
|
this.moniker = moniker;
|
||||||
this.emitter = new EVENTS.EventEmitter();
|
this.emitter = new EVENTS.EventEmitter();
|
||||||
},
|
},
|
||||||
|
|
||||||
on: function() {
|
on: function() {
|
||||||
this.emitter.on.apply( this.emitter, arguments );
|
this.emitter.on.apply( this.emitter, arguments );
|
||||||
|
},
|
||||||
|
|
||||||
|
fire: function(evtName, payload) {
|
||||||
|
payload = payload || { };
|
||||||
|
payload.cmd = this.moniker;
|
||||||
|
this.emitter.emit( 'hmr:' + evtName, payload );
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
stat: function( subEvent, payload ) {
|
||||||
|
payload = payload || { };
|
||||||
|
payload.cmd = this.moniker;
|
||||||
|
payload.sub = subEvent;
|
||||||
|
this.emitter.emit( 'hmr:status', payload );
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -40,6 +40,7 @@ Definition of the HtmlPdfCLIGenerator class.
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
var safe_eng = info.opts.pdf || 'wkhtmltopdf';
|
var safe_eng = info.opts.pdf || 'wkhtmltopdf';
|
||||||
|
if( safe_eng !== 'none' )
|
||||||
engines[ safe_eng ].call( this, info.mk, info.outputFile );
|
engines[ safe_eng ].call( this, info.mk, info.outputFile );
|
||||||
return null; // halt further processing
|
return null; // halt further processing
|
||||||
}
|
}
|
||||||
@ -47,12 +48,9 @@ Definition of the HtmlPdfCLIGenerator class.
|
|||||||
// { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', ... }
|
// { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', ... }
|
||||||
// { [Error: ENOENT] }
|
// { [Error: ENOENT] }
|
||||||
throw ( ex.inner && ex.inner.code === 'ENOENT' ) ?
|
throw ( ex.inner && ex.inner.code === 'ENOENT' ) ?
|
||||||
|
|
||||||
{ fluenterror: this.codes.notOnPath, inner: ex.inner, engine: ex.cmd,
|
{ fluenterror: this.codes.notOnPath, inner: ex.inner, engine: ex.cmd,
|
||||||
stack: ex.inner && ex.inner.stack } :
|
stack: ex.inner && ex.inner.stack } :
|
||||||
|
{ fluenterror: this.codes.pdfGeneration, inner: ex, stack: ex.stack };
|
||||||
{ fluenterror: this.codes.pdfGeneration, inner: ex.inner,
|
|
||||||
stack: ex.inner && ex.inner.stack };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +169,7 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
|||||||
{ outputFile: fileName, mk: file.data, opts: that.opts } );
|
{ outputFile: fileName, mk: file.data, opts: that.opts } );
|
||||||
}
|
}
|
||||||
catch(ex) {
|
catch(ex) {
|
||||||
|
console.log(ex);
|
||||||
require('../core/error-handler').err(ex, false);
|
require('../core/error-handler').err(ex, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,6 +180,7 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
|||||||
FS.copySync( file.info.path, thisFilePath );
|
FS.copySync( file.info.path, thisFilePath );
|
||||||
}
|
}
|
||||||
catch(ex) {
|
catch(ex) {
|
||||||
|
console.log('B');
|
||||||
ex.showStack = true;
|
ex.showStack = true;
|
||||||
require('../core/error-handler').err( ex );
|
require('../core/error-handler').err( ex );
|
||||||
}
|
}
|
||||||
|
38
src/main.js
38
src/main.js
@ -1,15 +1,15 @@
|
|||||||
|
/**
|
||||||
|
Definition of the `main` function.
|
||||||
|
@module main.js
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Main function for HackMyResume
|
|
||||||
@license MIT. See LICENSE.md for details.
|
|
||||||
@module main.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var HMR = require( './hackmyapi')
|
var HMR = require( './hackmyapi')
|
||||||
, PKG = require('../package.json')
|
, PKG = require('../package.json')
|
||||||
, FS = require('fs')
|
, FS = require('fs')
|
||||||
@ -17,17 +17,21 @@
|
|||||||
, chalk = require('chalk')
|
, chalk = require('chalk')
|
||||||
, PATH = require('path')
|
, PATH = require('path')
|
||||||
, HACKMYSTATUS = require('./core/status-codes')
|
, HACKMYSTATUS = require('./core/status-codes')
|
||||||
|
, HME = require('./core/event-codes')
|
||||||
, safeLoadJSON = require('./utils/safe-json-loader')
|
, safeLoadJSON = require('./utils/safe-json-loader')
|
||||||
, _opts = { }
|
, _opts = { }
|
||||||
, title = chalk.white.bold('\n*** HackMyResume v' + PKG.version + ' ***')
|
, title = chalk.white.bold('\n*** HackMyResume v' + PKG.version + ' ***')
|
||||||
, StringUtils = require('./utils/string.js')
|
, StringUtils = require('./utils/string.js')
|
||||||
, _ = require('underscore')
|
, _ = require('underscore')
|
||||||
|
, OUTPUT = require('./out')
|
||||||
, Command = require('commander').Command;
|
, Command = require('commander').Command;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Kick off the HackMyResume application.
|
Main function for HackMyResume
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module main.js
|
||||||
*/
|
*/
|
||||||
var main = module.exports = function( args ) {
|
var main = module.exports = function( args ) {
|
||||||
|
|
||||||
@ -117,8 +121,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Massage command-line args and setup Commander.js.
|
Massage command-line args and setup Commander.js.
|
||||||
*/
|
*/
|
||||||
@ -163,11 +165,14 @@
|
|||||||
Invoke a HackMyResume verb.
|
Invoke a HackMyResume verb.
|
||||||
*/
|
*/
|
||||||
function execVerb( src, dst, opts, log ) {
|
function execVerb( src, dst, opts, log ) {
|
||||||
loadOptions.call( this, opts );
|
|
||||||
require('./core/error-handler').init( _opts.debug );
|
|
||||||
|
|
||||||
|
loadOptions.call( this, opts );
|
||||||
|
require( './core/error-handler' ).init( _opts.debug );
|
||||||
|
var out = new OUTPUT( _opts );
|
||||||
var v = new HMR.verbs[ this.name() ]();
|
var v = new HMR.verbs[ this.name() ]();
|
||||||
v.invoke.call( null, src, dst, _opts, log );
|
v.on( 'hmr:status', function() { out.do.apply( out, arguments ); });
|
||||||
|
v.invoke.call( v, src, dst, _opts, log );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -176,9 +181,7 @@
|
|||||||
Initialize HackMyResume options.
|
Initialize HackMyResume options.
|
||||||
*/
|
*/
|
||||||
function loadOptions( o ) {
|
function loadOptions( o ) {
|
||||||
|
|
||||||
o.opts = this.parent.opts;
|
o.opts = this.parent.opts;
|
||||||
|
|
||||||
// Load the specified options file (if any) and apply options
|
// Load the specified options file (if any) and apply options
|
||||||
if( o.opts && String.is( o.opts )) {
|
if( o.opts && String.is( o.opts )) {
|
||||||
var json = safeLoadJSON( PATH.relative( process.cwd(), o.opts ) );
|
var json = safeLoadJSON( PATH.relative( process.cwd(), o.opts ) );
|
||||||
@ -187,7 +190,6 @@
|
|||||||
throw safeLoadJSON.error;
|
throw safeLoadJSON.error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge in command-line options
|
// Merge in command-line options
|
||||||
o = EXTEND( true, o, this.opts() );
|
o = EXTEND( true, o, this.opts() );
|
||||||
o.silent = this.parent.silent;
|
o.silent = this.parent.silent;
|
||||||
@ -237,4 +239,6 @@
|
|||||||
_opts.silent || console.log( msg );
|
_opts.silent || console.log( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
133
src/out.js
Normal file
133
src/out.js
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/**
|
||||||
|
Output routines for HackMyResume.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module out.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var chalk = require('chalk')
|
||||||
|
, HME = require('./core/event-codes')
|
||||||
|
, _ = require('underscore')
|
||||||
|
, Class = require('./utils/class.js')
|
||||||
|
, PATH = require('path')
|
||||||
|
, pad = require('string-padding');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
A stateful output handler.
|
||||||
|
*/
|
||||||
|
var OutputHandler = module.exports = Class.extend({
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
init: function( opts ) {
|
||||||
|
this.opts = opts;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
log: function( msg ) {
|
||||||
|
msg = msg || '';
|
||||||
|
this.opts.silent || console.log( msg );
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
do: function( evt ) {
|
||||||
|
|
||||||
|
switch( evt.sub ) {
|
||||||
|
|
||||||
|
case HME.beforeCreate:
|
||||||
|
this.log( chalk.green('Creating new ') +
|
||||||
|
chalk.green.bold(evt.cmd) +
|
||||||
|
chalk.green(' resume: ') + chalk.green.bold(evt.file));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.afterTheme:
|
||||||
|
this.theme = evt.theme;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.beforeMerge:
|
||||||
|
var msg = '';
|
||||||
|
evt.f.reverse().forEach( function( a, idx ) {
|
||||||
|
msg += ((idx === 0) ? chalk.cyan('Merging ') : chalk.cyan(' onto '))
|
||||||
|
+ chalk.cyan.bold(a.i().file);
|
||||||
|
});
|
||||||
|
this.log( msg );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.afterMerge:
|
||||||
|
var numFormats = Object.keys(this.theme.formats).length;
|
||||||
|
this.log( chalk.yellow('Applying ') +
|
||||||
|
chalk.yellow.bold( this.theme.name.toUpperCase() ) +
|
||||||
|
chalk.yellow(' theme (' + numFormats + ' format' +
|
||||||
|
( evt.numFormats === 1 ? ')' : 's)') ));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.end:
|
||||||
|
if( evt.cmd === 'build' ) {
|
||||||
|
var themeName = this.theme.name.toUpperCase();
|
||||||
|
if( this.opts.tips && (this.theme.message || this.theme.render) ) {
|
||||||
|
var WRAP = require('word-wrap');
|
||||||
|
if( this.theme.message ) {
|
||||||
|
this.log( WRAP( chalk.gray('The ' + themeName + ' theme says: "') +
|
||||||
|
chalk.white(this.theme.message) + chalk.gray('"'),
|
||||||
|
{ width: this.opts.wrap, indent: '' } ));
|
||||||
|
}
|
||||||
|
else if ( this.theme.render ) {
|
||||||
|
this.log( WRAP( chalk.gray('The ' + themeName +
|
||||||
|
' theme says: "') + chalk.white('For best results view JSON ' +
|
||||||
|
'Resume themes over a local or remote HTTP connection. For ' +
|
||||||
|
'example:'), { width: this.opts.wrap, indent: '' }
|
||||||
|
));
|
||||||
|
this.log( '');
|
||||||
|
this.log(
|
||||||
|
' npm install http-server -g\r' +
|
||||||
|
' http-server <resume-folder>' );
|
||||||
|
this.log('');
|
||||||
|
this.log(chalk.white('For more information, see the README."'),
|
||||||
|
{ width: this.opts.wrap, indent: '' } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.beforeGenerate:
|
||||||
|
var suffix = '';
|
||||||
|
if( evt.fmt === 'pdf' ) {
|
||||||
|
if( this.opts.pdf ) {
|
||||||
|
if( this.opts.pdf !== 'none' ) {
|
||||||
|
suffix = chalk.green(' (with ' + this.opts.pdf + ')');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.log( chalk.gray('Skipping ') +
|
||||||
|
chalk.white.bold( pad(evt.fmt.toUpperCase(),4,null,pad.RIGHT)) +
|
||||||
|
chalk.gray(' resume') + suffix + chalk.green(': ') +
|
||||||
|
chalk.white( evt.file ));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.log( chalk.green('Generating ') +
|
||||||
|
chalk.green.bold(
|
||||||
|
pad(evt.fmt.toUpperCase(),4,null,pad.RIGHT)) +
|
||||||
|
chalk.green(' resume') + suffix + chalk.green(': ') +
|
||||||
|
chalk.green.bold( PATH.relative(process.cwd(), evt.file )) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}());
|
@ -16,6 +16,7 @@ Implementation of the 'generate' verb for HackMyResume.
|
|||||||
, MKDIRP = require('mkdirp')
|
, MKDIRP = require('mkdirp')
|
||||||
, EXTEND = require('../utils/extend')
|
, EXTEND = require('../utils/extend')
|
||||||
, HACKMYSTATUS = require('../core/status-codes')
|
, HACKMYSTATUS = require('../core/status-codes')
|
||||||
|
, HME = require('../core/event-codes')
|
||||||
, parsePath = require('parse-filepath')
|
, parsePath = require('parse-filepath')
|
||||||
, _opts = require('../core/default-options')
|
, _opts = require('../core/default-options')
|
||||||
, FluentTheme = require('../core/fresh-theme')
|
, FluentTheme = require('../core/fresh-theme')
|
||||||
@ -33,7 +34,7 @@ Implementation of the 'generate' verb for HackMyResume.
|
|||||||
var BuildVerb = module.exports = Verb.extend({
|
var BuildVerb = module.exports = Verb.extend({
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super();
|
this._super('build');
|
||||||
},
|
},
|
||||||
|
|
||||||
invoke: function() {
|
invoke: function() {
|
||||||
@ -52,12 +53,15 @@ Implementation of the 'generate' verb for HackMyResume.
|
|||||||
*/
|
*/
|
||||||
function build( src, dst, opts, logger, errHandler ) {
|
function build( src, dst, opts, logger, errHandler ) {
|
||||||
|
|
||||||
|
this.stat( HME.begin );
|
||||||
|
|
||||||
prep( src, dst, opts, logger, errHandler );
|
prep( src, dst, opts, logger, errHandler );
|
||||||
|
|
||||||
// Load the theme...we do this first because the theme choice (FRESH or
|
// Load the theme...we do this first because the theme choice (FRESH or
|
||||||
// JSON Resume) determines what format we'll convert the resume to.
|
// JSON Resume) determines what format we'll convert the resume to.
|
||||||
var tFolder = verifyTheme( _opts.theme );
|
var tFolder = verifyTheme( _opts.theme );
|
||||||
var theme = loadTheme( tFolder );
|
var theme = loadTheme( tFolder );
|
||||||
|
this.stat( HME.afterTheme, { theme: theme });
|
||||||
|
|
||||||
// Check for invalid outputs
|
// Check for invalid outputs
|
||||||
var inv = verifyOutputs( dst, theme );
|
var inv = verifyOutputs( dst, theme );
|
||||||
@ -73,53 +77,26 @@ Implementation of the 'generate' verb for HackMyResume.
|
|||||||
}).map(function(sh){ return sh.rez; });
|
}).map(function(sh){ return sh.rez; });
|
||||||
|
|
||||||
// Merge input resumes...
|
// Merge input resumes...
|
||||||
var msg = '';
|
(sheets.length > 1) && this.stat( HME.beforeMerge, { f: _.clone(sheets) });
|
||||||
rez = _.reduceRight( sheets, function( a, b, idx ) {
|
rez = _.reduceRight( sheets, function( a, b, idx ) {
|
||||||
msg += ((idx == sheets.length - 2) ?
|
|
||||||
chalk.cyan('Merging ') + chalk.cyan.bold(a.i().file) : '') +
|
|
||||||
chalk.cyan(' onto ') + chalk.cyan.bold(b.i().file);
|
|
||||||
return extend( true, b, a );
|
return extend( true, b, a );
|
||||||
});
|
});
|
||||||
msg && _log(msg);
|
(sheets.length > 1) && this.stat( HME.afterMerge, { r: rez } );
|
||||||
|
|
||||||
// Output theme messages
|
// Output theme messages
|
||||||
var numFormats = Object.keys(theme.formats).length;
|
var numFormats = Object.keys(theme.formats).length;
|
||||||
var themeName = theme.name.toUpperCase();
|
var themeName = theme.name.toUpperCase();
|
||||||
_log( chalk.yellow('Applying ') + chalk.yellow.bold(themeName) +
|
|
||||||
chalk.yellow(' theme (' + numFormats + ' format' +
|
|
||||||
( numFormats === 1 ? ')' : 's)') ));
|
|
||||||
|
|
||||||
// Expand output resumes...
|
// Expand output resumes...
|
||||||
var targets = expand( dst, theme );
|
var targets = expand( dst, theme );
|
||||||
|
|
||||||
// Run the transformation!
|
// Run the transformation!
|
||||||
targets.forEach( function(t) {
|
_.each(targets, function(t) {
|
||||||
t.final = single( t, theme, targets );
|
t.final = single.call( this, t, theme, targets );
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
if( _opts.tips && (theme.message || theme.render) ) {
|
|
||||||
var WRAP = require('word-wrap');
|
|
||||||
if( theme.message ) {
|
|
||||||
_log( WRAP( chalk.gray('The ' + themeName +
|
|
||||||
' theme says: "') + chalk.white(theme.message) + chalk.gray('"'),
|
|
||||||
{ width: _opts.wrap, indent: '' } ));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_log( WRAP( chalk.gray('The ' + themeName +
|
|
||||||
' theme says: "') + chalk.white('For best results view JSON Resume ' +
|
|
||||||
'themes over a local or remote HTTP connection. For example:'),
|
|
||||||
{ width: _opts.wrap, indent: '' }
|
|
||||||
));
|
|
||||||
_log('');
|
|
||||||
_log(
|
|
||||||
' npm install http-server -g\r' +
|
|
||||||
' http-server <resume-folder>' );
|
|
||||||
_log('');
|
|
||||||
_log(chalk.white('For more information, see the README."'),
|
|
||||||
{ width: _opts.wrap, indent: '' } );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
this.stat( HME.end );
|
||||||
|
|
||||||
// Don't send the client back empty-handed
|
// Don't send the client back empty-handed
|
||||||
return { sheet: rez, targets: targets, processed: targets };
|
return { sheet: rez, targets: targets, processed: targets };
|
||||||
@ -172,28 +149,10 @@ Implementation of the 'generate' verb for HackMyResume.
|
|||||||
, fName = PATH.basename(f, '.' + fType)
|
, fName = PATH.basename(f, '.' + fType)
|
||||||
, theFormat;
|
, theFormat;
|
||||||
|
|
||||||
var suffix = '';
|
this.stat( HME.beforeGenerate, {
|
||||||
if( targInfo.fmt.outFormat === 'pdf' ) {
|
fmt: targInfo.fmt.outFormat,
|
||||||
if( _opts.pdf ) {
|
file: PATH.relative(process.cwd(), f)
|
||||||
if( _opts.pdf !== 'none' ) {
|
});
|
||||||
suffix = chalk.green(' (with ' + _opts.pdf + ')');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_log( chalk.gray('Skipping ') +
|
|
||||||
chalk.white.bold(
|
|
||||||
pad(targInfo.fmt.outFormat.toUpperCase(),4,null,pad.RIGHT)) +
|
|
||||||
chalk.gray(' resume') + suffix + chalk.green(': ') +
|
|
||||||
chalk.white( PATH.relative(process.cwd(), f )) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_log( chalk.green('Generating ') +
|
|
||||||
chalk.green.bold(
|
|
||||||
pad(targInfo.fmt.outFormat.toUpperCase(),4,null,pad.RIGHT)) +
|
|
||||||
chalk.green(' resume') + suffix + chalk.green(': ') +
|
|
||||||
chalk.green.bold( PATH.relative(process.cwd(), f )) );
|
|
||||||
|
|
||||||
// If targInfo.fmt.files exists, this format is backed by a document.
|
// If targInfo.fmt.files exists, this format is backed by a document.
|
||||||
// Fluent/FRESH themes are handled here.
|
// Fluent/FRESH themes are handled here.
|
||||||
|
@ -4,17 +4,28 @@ Implementation of the 'create' verb for HackMyResume.
|
|||||||
@license MIT. See LICENSE.md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var MKDIRP = require('mkdirp')
|
var MKDIRP = require('mkdirp')
|
||||||
, PATH = require('path')
|
, PATH = require('path')
|
||||||
, chalk = require('chalk')
|
, chalk = require('chalk')
|
||||||
, Verb = require('../core/verb')
|
, Verb = require('../core/verb')
|
||||||
, HACKMYSTATUS = require('../core/status-codes');
|
, _ = require('underscore')
|
||||||
|
, HACKMYSTATUS = require('../core/status-codes')
|
||||||
|
, HME = require('../core/event-codes');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var CreateVerb = module.exports = Verb.extend({
|
var CreateVerb = module.exports = Verb.extend({
|
||||||
|
|
||||||
|
init: function() {
|
||||||
|
this._super('new');
|
||||||
|
},
|
||||||
|
|
||||||
invoke: function() {
|
invoke: function() {
|
||||||
create.apply( this, arguments );
|
create.apply( this, arguments );
|
||||||
}
|
}
|
||||||
@ -22,21 +33,27 @@ Implementation of the 'create' verb for HackMyResume.
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a new empty resume in either FRESH or JRS format.
|
Create a new empty resume in either FRESH or JRS format.
|
||||||
*/
|
*/
|
||||||
function create( src, dst, opts, logger ) {
|
function create( src, dst, opts/*, logger*/ ) {
|
||||||
var _log = logger || console.log;
|
|
||||||
if( !src || !src.length ) throw { fluenterror: HACKMYSTATUS.createNameMissing };
|
if(!src || !src.length) throw {fluenterror: HACKMYSTATUS.createNameMissing};
|
||||||
src.forEach( function( t ) {
|
this.stat( HME.begin );
|
||||||
var safeFormat = opts.format.toUpperCase();
|
|
||||||
_log(chalk.green('Creating new ') + chalk.green.bold(safeFormat) +
|
_.each( src, function( t ) {
|
||||||
chalk.green(' resume: ') + chalk.green.bold(t));
|
var safeFmt = opts.format.toUpperCase();
|
||||||
|
this.fireStat( HME.bc, { fmt: safeFmt, file: t } );
|
||||||
MKDIRP.sync( PATH.dirname( t ) ); // Ensure dest folder exists;
|
MKDIRP.sync( PATH.dirname( t ) ); // Ensure dest folder exists;
|
||||||
var RezClass = require('../core/' + safeFormat.toLowerCase() + '-resume' );
|
var RezClass = require('../core/' + safeFmt.toLowerCase() + '-resume' );
|
||||||
RezClass.default().save(t);
|
RezClass.default().save(t);
|
||||||
//FLUENT[ safeFormat + 'Resume' ].default().save( t );
|
this.fireStat( HME.ac, { fmt: safeFmt, file: t } );
|
||||||
});
|
}, this);
|
||||||
|
|
||||||
|
this.stat( HME.end );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
Loading…
Reference in New Issue
Block a user