mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 08:20:11 +00:00
Add external logger callback.
This commit is contained in:
parent
fe9af2d334
commit
e622918fee
@ -16,7 +16,7 @@ module.exports = function () {
|
|||||||
, unused = require('./utils/string')
|
, unused = require('./utils/string')
|
||||||
, FLUENT = require('fluentlib');
|
, FLUENT = require('fluentlib');
|
||||||
|
|
||||||
var rez;
|
var rez, _log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Core resume generation method for HMR. Given a source JSON resume file, a
|
Core resume generation method for HMR. Given a source JSON resume file, a
|
||||||
@ -27,8 +27,9 @@ module.exports = function () {
|
|||||||
@param dst Path to the destination resume file(s): "rez/resume.all".
|
@param dst Path to the destination resume file(s): "rez/resume.all".
|
||||||
@param theme Friendly name of the resume theme. Defaults to "default".
|
@param theme Friendly name of the resume theme. Defaults to "default".
|
||||||
*/
|
*/
|
||||||
function hmr( src, dst, theme ) {
|
function hmr( src, dst, theme, logger ) {
|
||||||
|
|
||||||
|
_log = logger || console.log;
|
||||||
_opts.theme = theme;
|
_opts.theme = theme;
|
||||||
dst = (dst && dst.length && dst) || ['resume.all'];
|
dst = (dst && dst.length && dst) || ['resume.all'];
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ module.exports = function () {
|
|||||||
|
|
||||||
// Assemble input resumes
|
// Assemble input resumes
|
||||||
var sheets = src.map( function( res ) {
|
var sheets = src.map( function( res ) {
|
||||||
console.log( 'Reading JSON resume: ' + res );
|
_log( 'Reading JSON resume: ' + res );
|
||||||
return (new FLUENT.Sheet()).open( res );
|
return (new FLUENT.Sheet()).open( res );
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ module.exports = function () {
|
|||||||
var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.ext );
|
var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.ext );
|
||||||
|
|
||||||
// Generate!
|
// Generate!
|
||||||
console.log( 'Generating ' + fType.toUpperCase() + ' resume: ' + fOut );
|
_log( 'Generating ' + fType.toUpperCase() + ' resume: ' + fOut );
|
||||||
return fObj.gen.generate( rez, fOut, _opts.theme );
|
return fObj.gen.generate( rez, fOut, _opts.theme );
|
||||||
}
|
}
|
||||||
catch( ex ) {
|
catch( ex ) {
|
||||||
@ -98,7 +99,7 @@ module.exports = function () {
|
|||||||
var msg = ex.toString();
|
var msg = ex.toString();
|
||||||
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.error( 'ERROR: ' + trimmed.toString() );
|
_log( 'ERROR: ' + trimmed.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user