mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-22 00:10:15 +00:00
Support "--no-prettify" option.
Add command-line support for "--no-prettify" and "-n". Use a negative option here since pretty printing is enabled by default.
This commit is contained in:
parent
2a7963450e
commit
68f943745c
@ -22,11 +22,14 @@ module.exports = function () {
|
||||
@param theme Friendly name of the resume theme. Defaults to "modern".
|
||||
@param logger Optional logging override.
|
||||
*/
|
||||
function gen( src, dst, theme, logger, errHandler ) {
|
||||
function gen( src, dst, opts, logger, errHandler ) {
|
||||
|
||||
_log = logger || console.log;
|
||||
_err = errHandler || error;
|
||||
_opts.theme = (theme && theme.toLowerCase().trim()) || 'modern';
|
||||
|
||||
//_opts = extend( true, _opts, opts );
|
||||
_opts.theme = (opts.theme && opts.theme.toLowerCase().trim()) || 'modern';
|
||||
_opts.prettify = opts.prettify === true ? _opts.prettify : false;
|
||||
|
||||
// Load input resumes...
|
||||
if(!src || !src.length) { throw { fluenterror: 3 }; }
|
||||
@ -71,7 +74,7 @@ module.exports = function () {
|
||||
var fObj = _fmts.filter( function(_f) { return _f.ext === fType; } )[0];
|
||||
var fOut = path.join( f.substring( 0, f.lastIndexOf('.') + 1 ) + fObj.ext );
|
||||
_log( 'Generating ' + fi.fmt.name.toUpperCase() + ' resume: ' + path.relative(process.cwd(), f ) );
|
||||
return fObj.gen.generate( rez, fOut, { theme: _opts.theme } );
|
||||
return fObj.gen.generate( rez, fOut, _opts );
|
||||
}
|
||||
catch( ex ) {
|
||||
_err( ex );
|
||||
@ -98,11 +101,17 @@ module.exports = function () {
|
||||
];
|
||||
|
||||
/**
|
||||
Default options.
|
||||
Default FluentCMD options.
|
||||
*/
|
||||
var _opts = {
|
||||
theme: 'modern',
|
||||
}
|
||||
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
|
||||
indent_size: 2,
|
||||
unformatted: ['em','strong'],
|
||||
max_char: 80, // ← See lib/html.js in above-linked repo
|
||||
//wrap_line_length: 120, ← Don't use this
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Internal module interface. Used by FCV Desktop and HMR.
|
||||
|
27
src/index.js
27
src/index.js
@ -10,17 +10,38 @@ var ARGS = require( 'minimist' )
|
||||
, PKG = require('../package.json');
|
||||
|
||||
try {
|
||||
main();
|
||||
}
|
||||
catch( ex ) {
|
||||
handleError( ex );
|
||||
}
|
||||
|
||||
function main() {
|
||||
// Setup.
|
||||
console.log( '*** FluentCMD v' + PKG.version + ' ***' );
|
||||
if( process.argv.length <= 2 ) { throw { fluenterror: 3 }; }
|
||||
|
||||
// Convert arguments to source files, target files, options
|
||||
var args = ARGS( process.argv.slice(2) );
|
||||
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' );
|
||||
dst = (dst === true) ? [] : dst; // Handle -o with missing output file
|
||||
|
||||
// Generate!
|
||||
FCMD.generate( src, dst, getOpts( args ) );
|
||||
process.platform !== 'win32' && console.log('\n');
|
||||
}
|
||||
catch( ex ) {
|
||||
|
||||
function getOpts( args ) {
|
||||
var noPretty = args['nopretty'] || args.n;
|
||||
noPretty = noPretty && (noPretty === true || noPretty === 'true');
|
||||
return {
|
||||
theme: args.t || 'modern',
|
||||
prettify: !noPretty
|
||||
};
|
||||
}
|
||||
|
||||
function handleError( ex ) {
|
||||
var msg = '';
|
||||
if( ex.fluenterror ){
|
||||
switch( ex.fluenterror ) { // TODO: Remove magic numbers
|
||||
|
Loading…
Reference in New Issue
Block a user