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

Always display title on error.

This commit is contained in:
devlinjd 2015-10-26 13:17:58 -04:00
parent 0d0b8a9d0b
commit e34d02facb

View File

@ -7,23 +7,28 @@ Command-line interface (CLI) for FluentCMD via Node.js.
var ARGS = require( 'minimist' )
, FCMD = require( './fluentcmd')
, PKG = require('../package.json');
, PKG = require('../package.json')
, opts = { };
try {
var opts = { };
main();
}
catch( ex ) {
handleError( ex );
}
function main() {
// 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) );
opts = getOpts( args );
logMsg( '*** FluentCMD v' + PKG.version + ' ***' );
logMsg( title );
// Convert arguments to source files, target files, options
var src = args._ || [];
@ -32,7 +37,8 @@ function main() {
// Generate!
FCMD.generate( src, dst, opts, logMsg );
process.platform !== 'win32' && console.log('\n');
process.exit(0);
}
function logMsg( msg ) {
@ -50,19 +56,23 @@ function getOpts( args ) {
}
function handleError( ex ) {
var msg = '';
var msg = '', exitCode;
if( 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;
};
exitCode = ex.fluenterror;
}
else {
msg = ex.toString();
exitCode = 4;
}
var idx = msg.indexOf('Error: ');
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
console.log( 'ERROR: ' + trimmed.toString() );
process.exit( exitCode );
}