mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-12-23 05:37:23 +00:00
Cleanup.
This commit is contained in:
parent
cbddb4b3aa
commit
992069b22d
@ -104,7 +104,7 @@ module.exports = function () {
|
||||
|
||||
var theFormat = _fmts.filter(
|
||||
function( fmt ) { return fmt.name === fi.fmt.pre; })[0];
|
||||
MKDIRP( path.dirname(fOut) ); // Ensure dest folder exists;
|
||||
MKDIRP.sync( path.dirname(fOut) ); // Ensure dest folder exists;
|
||||
theFormat.gen.generate( rez, fOut, _opts );
|
||||
}
|
||||
catch( ex ) {
|
||||
@ -196,7 +196,8 @@ module.exports = function () {
|
||||
*/
|
||||
function convert( src, dst, opts, logger ) {
|
||||
_log = logger || console.log;
|
||||
if( !src || src.length !== 1 ) { throw { fluenterror: 3 }; }
|
||||
if( !src || !src.length ) { throw { fluenterror: 3 }; }
|
||||
if( !dst || !dst.length ) { throw { fluenterror: 5 }; }
|
||||
var sheet = loadSourceResumes( src )[ 0 ];
|
||||
var sourceFormat = sheet.imp.orgFormat === 'JRS' ? 'JRS' : 'FRESH';
|
||||
var targetFormat = sourceFormat === 'JRS' ? 'FRESH' : 'JRS';
|
||||
@ -243,7 +244,7 @@ module.exports = function () {
|
||||
*/
|
||||
return {
|
||||
verbs: {
|
||||
generate: generate,
|
||||
build: generate,
|
||||
validate: validate,
|
||||
convert: convert
|
||||
},
|
||||
|
@ -19,9 +19,9 @@ var JsonGenerator = module.exports = BaseGenerator.extend({
|
||||
invoke: function( rez ) {
|
||||
// TODO: merge with FCVD
|
||||
function replacer( key,value ) { // Exclude these keys from stringification
|
||||
return _.some(['meta', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
||||
'isModified', 'htmlPreview'],
|
||||
'isModified', 'htmlPreview', 'safe' ],
|
||||
function( val ) { return key.trim() === val; }
|
||||
) ? undefined : value;
|
||||
}
|
||||
|
@ -127,7 +127,6 @@ var TemplateGenerator = module.exports = BaseGenerator.extend({
|
||||
|
||||
// Strip {# comments #}
|
||||
jst = jst.replace( _.templateSettings.comment, '');
|
||||
json.display_progress_bar = true;
|
||||
|
||||
// Compile and run the template. TODO: avoid unnecessary recompiles.
|
||||
jst = _.template(jst)({ r: json, filt: this.opts.filters, cssInfo: cssInfo, headFragment: this.opts.headFragment || '' });
|
||||
|
33
src/index.js
33
src/index.js
@ -9,7 +9,8 @@ var ARGS = require( 'minimist' )
|
||||
, FCMD = require( './fluentcmd')
|
||||
, PKG = require('../package.json')
|
||||
, opts = { }
|
||||
, title = ('*** FluentCV v' + PKG.version + ' ***').white.bold;
|
||||
, title = ('*** FluentCV v' + PKG.version + ' ***').white.bold
|
||||
, _ = require('underscore');
|
||||
|
||||
|
||||
|
||||
@ -30,16 +31,28 @@ function main() {
|
||||
logMsg( title );
|
||||
|
||||
// Get the action to be performed
|
||||
var verb = a._[0].toLowerCase().trim();
|
||||
var params = a._.map( function(p){ return p.toLowerCase().trim(); });
|
||||
var verb = params[0];
|
||||
if( !FCMD.verbs[ verb ] ) {
|
||||
logMsg('Invalid command: "'.yellow + verb.yellow.bold + '"'.yellow);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get source and dest params
|
||||
var splitAt = _.indexOf( params, 'to' );
|
||||
if( splitAt === a._.length - 1 ) {
|
||||
// 'TO' cannot be the last argument
|
||||
logMsg('Please '.gray + 'specify an output file' + ' for this operation or '.gray + 'omit the TO keyword' + '.'.gray);
|
||||
return;
|
||||
}
|
||||
|
||||
var src = a._.slice(1, splitAt === -1 ? undefined : splitAt );
|
||||
var dst = splitAt === -1 ? [] : a._.slice( splitAt + 1 );
|
||||
|
||||
// Preload our params array
|
||||
var dst = (a.o && ((typeof a.o === 'string' && [ a.o ]) || a.o)) || [];
|
||||
dst = (dst === true) ? [] : dst; // Handle -o with missing output file
|
||||
var parms = [ a._.slice(1) || [], dst, opts, logMsg ];
|
||||
//var dst = (a.o && ((typeof a.o === 'string' && [ a.o ]) || a.o)) || [];
|
||||
//dst = (dst === true) ? [] : dst; // Handle -o with missing output file
|
||||
var parms = [ src, dst, opts, logMsg ];
|
||||
|
||||
// Invoke the action
|
||||
FCMD.verbs[ verb ].apply( null, parms );
|
||||
@ -66,12 +79,14 @@ function handleError( ex ) {
|
||||
switch( ex.fluenterror ) { // TODO: Remove magic numbers
|
||||
case 1: msg = "The specified theme couldn't be found: " + ex.data; break;
|
||||
case 2: msg = "Couldn't copy CSS file to destination folder"; break;
|
||||
case 3: msg = "Please specify a valid SOURCE resume in FRESH or JSON Resume format.".gray; break;
|
||||
case 4: msg = title + "\nPlease specify a valid command (".gray +
|
||||
case 3: msg = 'Please '.gray + 'specify a valid input resume' + ' in '.gray + 'FRESH' + ' or '.gray + 'JSON Resume' + ' format.'.gray; break;
|
||||
case 4: msg = title + "\nPlease specify a command (".gray +
|
||||
Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
|
||||
return (idx === ar.length - 1 ? 'or '.gray : '')
|
||||
+ v.toUpperCase().white.bold;
|
||||
+ v.toUpperCase();
|
||||
}).join(', ') + ")";
|
||||
break;
|
||||
case 5: msg = "Please specify the name of the TARGET file to convert to.".gray;
|
||||
};
|
||||
exitCode = ex.fluenterror;
|
||||
}
|
||||
@ -82,7 +97,7 @@ function handleError( ex ) {
|
||||
|
||||
var idx = msg.indexOf('Error: ');
|
||||
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
|
||||
if( !ex.fluenterror || ex.fluenterror !== 4 && ex.fluenterror !== 3 )
|
||||
if( !ex.fluenterror || ex.fluenterror < 3 )
|
||||
console.log( ('ERROR: ' + trimmed.toString()).red.bold );
|
||||
else
|
||||
console.log( trimmed.toString() );
|
||||
|
Loading…
Reference in New Issue
Block a user