1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-25 09:50:11 +00:00

Merge pull request #8 from fluentdesk/fix/title

Always display title on error.
This commit is contained in:
JD 2015-10-26 13:14:32 -04:00
commit 6f578f9d44

View File

@ -7,23 +7,28 @@ Command-line interface (CLI) for FluentCMD via Node.js.
var ARGS = require( 'minimist' ) var ARGS = require( 'minimist' )
, FCMD = require( './fluentcmd') , FCMD = require( './fluentcmd')
, PKG = require('../package.json'); , PKG = require('../package.json')
, opts = { };
try { try {
var opts = { };
main(); main();
} }
catch( ex ) { catch( ex ) {
handleError( ex ); handleError( ex );
} }
function main() { function main() {
// Setup. // Setup.
if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; } var title = '*** FluentCMD v' + PKG.version + ' ***';
if( process.argv.length <= 2 ) { logMsg(title); throw { fluenterror: 3 }; }
var args = ARGS( process.argv.slice(2) ); var args = ARGS( process.argv.slice(2) );
opts = getOpts( args ); opts = getOpts( args );
logMsg( '*** FluentCMD v' + PKG.version + ' ***' ); logMsg( title );
// Convert arguments to source files, target files, options // Convert arguments to source files, target files, options
var src = args._ || []; var src = args._ || [];
@ -32,7 +37,8 @@ function main() {
// Generate! // Generate!
FCMD.generate( src, dst, opts, logMsg ); FCMD.generate( src, dst, opts, logMsg );
process.platform !== 'win32' && console.log('\n');
process.exit(0);
} }
function logMsg( msg ) { function logMsg( msg ) {
@ -50,19 +56,23 @@ function getOpts( args ) {
} }
function handleError( ex ) { function handleError( ex ) {
var msg = ''; var msg = '', exitCode;
if( ex.fluenterror ){ if( ex.fluenterror ){
switch( ex.fluenterror ) { // TODO: Remove magic numbers switch( ex.fluenterror ) { // TODO: Remove magic numbers
case 1: msg = "The specified theme couldn't be found: " + ex.data; break; 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 2: msg = "Couldn't copy CSS file to destination folder"; break;
case 3: msg = "Please specify a valid JSON resume file."; break; case 3: msg = "Please specify a valid JSON resume file."; break;
}; };
exitCode = ex.fluenterror;
} }
else { else {
msg = ex.toString(); msg = ex.toString();
exitCode = 4;
} }
var idx = msg.indexOf('Error: '); var idx = msg.indexOf('Error: ');
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 ); var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
console.log( 'ERROR: ' + trimmed.toString() ); console.log( 'ERROR: ' + trimmed.toString() );
process.exit( exitCode );
} }