1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 15:57:07 +01:00

Replace colors with chalk.

Chalk has a few more options and doesn't mess around with
String.prototype.
This commit is contained in:
hacksalot
2016-01-01 04:44:14 -05:00
parent d54b9a6d6c
commit cb14452df3
10 changed files with 72 additions and 68 deletions

View File

@ -39,8 +39,8 @@ Implementation of the 'analyze' verb for HackMyResume.
function _analyze( resumeObject, nlzrs, opts, log ) {
var rez = resumeObject.rez;
var safeFormat = rez.meta.format.startsWith('FRESH') ? 'FRESH' : 'JRS';
log('Analyzing '.useful + safeFormat.useful.bold +
' resume: '.useful + resumeObject.file.useful.bold);
log(chalk.cyan('Analyzing ') + chalk.cyan.bold(safeFormat) +
chalk.cyan(' resume: ') + chalk.cyan.bold(resumeObject.file));
var info = _.mapObject( nlzrs, function(val, key) {
return val.run( resumeObject.rez );
});

View File

@ -27,9 +27,9 @@ Implementation of the 'convert' verb for HackMyResume.
var sheet = src.rez;
var sourceFormat = ((sheet.basics && sheet.basics.imp) || sheet.imp).orgFormat === 'JRS' ? 'JRS' : 'FRESH';
var targetFormat = sourceFormat === 'JRS' ? 'FRESH' : 'JRS';
_log( 'Converting '.useful + src.file.useful.bold + (' (' +
sourceFormat + ') to ').useful + dst[0].useful.bold +
(' (' + targetFormat + ').').useful );
_log( chalk.green('Converting ') + chalk.green.bold(src.file) + chalk.green(' (' +
sourceFormat + ') to ') + chalk.green.bold(dst[0]) +
chalk.green(' (' + targetFormat + ').') );
sheet.saveAs( dst[idx], targetFormat );
});
};

View File

@ -18,8 +18,8 @@ Implementation of the 'create' verb for HackMyResume.
if( !src || !src.length ) throw { fluenterror: 8 };
src.forEach( function( t ) {
var safeFormat = opts.format.toUpperCase();
_log('Creating new '.useful +safeFormat.useful.bold +
' resume: '.useful + t.useful.bold);
_log(chalk.green('Creating new ') + chalk.green.bold(safeFormat) +
chalk.green(' resume: ') + chalk.green.bold(t));
MKDIRP.sync( PATH.dirname( t ) ); // Ensure dest folder exists;
FLUENT[ safeFormat + 'Resume' ].default().save( t );
});

View File

@ -21,6 +21,7 @@ Implementation of the 'generate' verb for HackMyResume.
, _ = require('underscore')
, _fmts = require('../core/default-formats')
, extend = require('../utils/extend')
, chalk = require('chalk')
, _err, _log, rez;
@ -64,9 +65,10 @@ Implementation of the 'generate' verb for HackMyResume.
var msg = '';
var rezRep = _.reduceRight( sheets, function( a, b, idx ) {
msg += ((idx == sheets.length - 2) ?
'Merging '.gray + a.rez.imp.fileName : '') + ' onto '.gray + b.rez.fileName;
chalk.gray('Merging ') + a.rez.imp.fileName : '') + chalk.gray(' onto ') + b.rez.fileName;
return extend( true, b.rez, a.rez );
});
rez = rezRep.rez;
msg && _log(msg);
@ -102,9 +104,9 @@ Implementation of the 'generate' verb for HackMyResume.
, fName = PATH.basename(f, '.' + fType)
, theFormat;
_log( 'Generating '.useful +
targInfo.fmt.outFormat.toUpperCase().useful.bold +
' resume: '.useful + PATH.relative(process.cwd(), f ).useful.bold );
_log( chalk.green('Generating ') +
chalk.green.bold(targInfo.fmt.outFormat.toUpperCase()) +
chalk.green(' resume: ') + chalk.green.bold( PATH.relative(process.cwd(), f )) );
// If targInfo.fmt.files exists, this format is backed by a document.
// Fluent/FRESH themes are handled here.
@ -273,8 +275,8 @@ Implementation of the 'generate' verb for HackMyResume.
// Output a message TODO: core should not log
var numFormats = Object.keys(theTheme.formats).length;
_log( 'Applying '.info + theTheme.name.toUpperCase().infoBold +
(' theme (' + numFormats + ' formats)').info);
_log( chalk.gray('Applying ') + chalk.gray.bold(theTheme.name.toUpperCase()) +
chalk.gray(' theme (' + numFormats + ' formats)'));
return theTheme;
}

View File

@ -9,6 +9,7 @@ Implementation of the 'validate' verb for HackMyResume.
var FS = require('fs');
var ResumeFactory = require('../core/resume-factory');
var SyntaxErrorEx = require('../utils/syntax-error-ex');
var chalk = require('chalk');
module.exports =
@ -31,25 +32,25 @@ Implementation of the 'validate' verb for HackMyResume.
var result = ResumeFactory.loadOne( src, function(){}, null, false );
if( result.error ) {
_log( 'Validating '.info + src.infoBold + ' against '.info + 'AUTO'.infoBold + ' schema:'.info + ' BROKEN'.red.bold );
_log( chalk.white('Validating ') + chalk.gray.bold(src) + chalk.white(' against ') + chalk.gray.bold('AUTO') + chalk.white(' schema:') + chalk.red.bold(' BROKEN') );
var ex = result.error; // alias
if ( ex instanceof SyntaxError) {
var info = new SyntaxErrorEx( ex, result.raw );
_log( ('--> '.warn.bold + src.toUpperCase() + ' contains invalid JSON on line ' +
info.line + ' column ' + info.col + '.').warn +
' Unable to validate.'.warn );
_log( (' INTERNAL: ' + ex).warn );
_log( chalk.red.bold('--> ') + chalk.red(src.toUpperCase() + ' contains invalid JSON on line ' +
info.line + ' column ' + info.col + '.') +
chalk.red(' Unable to validate.') );
_log( chalk.red(' INTERNAL: ' + ex) );
}
else {
_log(('ERROR: ' + ex.toString()).warn.bold);
_log(chalk.red.bold('ERROR: ' + ex.toString()));
}
return;
}
var json = result.json;
var isValid = false;
var style = 'useful';
var style = 'green';
var errors = [];
var fmt = json.meta && (json.meta.format==='FRESH@0.1.0') ? 'fresh':'jars';
@ -62,7 +63,7 @@ Implementation of the 'validate' verb for HackMyResume.
isValid = validate( json );
if( !isValid ) {
style = 'warn';
style = 'yellow';
errors = validate.errors;
}
@ -71,14 +72,14 @@ Implementation of the 'validate' verb for HackMyResume.
return;
}
_log( 'Validating '.info + result.file.infoBold + ' against '.info +
fmt.replace('jars','JSON Resume').toUpperCase().infoBold +
' schema: '.info + (isValid ? 'VALID!' : 'INVALID')[style].bold );
_log( chalk.white('Validating ') + chalk.white.bold(result.file) + chalk.white(' against ') +
chalk.white.bold(fmt.replace('jars','JSON Resume').toUpperCase()) +
chalk.white(' schema: ') + chalk[style].bold(isValid ? 'VALID!' : 'INVALID') );
errors.forEach(function(err,idx) {
_log( '--> '.bold.yellow +
(err.field.replace('data.','resume.').toUpperCase() + ' ' +
err.message).yellow );
_log( chalk.yellow.bold('--> ') +
chalk.yellow(err.field.replace('data.','resume.').toUpperCase() + ' ' +
err.message) );
});
});