From 2e5a68d94258c7c931d5af96be730b3398021f02 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Sat, 10 Oct 2015 21:39:32 -0400 Subject: [PATCH] Support explicit -o output parameter. Allow output files to be explicitly specified via -o, for ex: fluentcmd resume.json -o out/resume.html -o out/resume.pdf --- src/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index f8d97d4..fd588e8 100644 --- a/src/index.js +++ b/src/index.js @@ -13,8 +13,9 @@ try { console.log( '*** FluentCMD v' + PKG.version + ' ***' ); if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; } var args = ARGS( process.argv.slice(2) ); - var src = args._.filter( function( a ) { return a.match(/\.json$/); }); - var dst = args._.filter( function( a ) { return !a.match(/\.json$/); }); + var src = args._ || []; + var dst = (args.o && ((typeof args.o === 'string' && [ args.o ]) || args.o)) || []; + dst = (dst === true) ? [] : dst; // handle -o with missing output file FCMD.generate( src, dst, args.t || 'modern' ); process.platform !== 'win32' && console.log('\n'); } @@ -22,7 +23,7 @@ catch( ex ) { var msg = ''; if( ex.fluenterror ){ - switch( ex.fluenterror ) { + 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 JSON resume file."; break;