mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-02 20:37:08 +01:00
Asynchrony.
This commit is contained in:
11
dist/cli/error.js
vendored
11
dist/cli/error.js
vendored
@ -35,8 +35,7 @@ Error-handling routines for HackMyResume.
|
||||
require('string.prototype.startswith');
|
||||
|
||||
|
||||
/**
|
||||
Error handler for HackMyResume. All errors are handled here.
|
||||
/** Error handler for HackMyResume. All errors are handled here.
|
||||
@class ErrorHandler
|
||||
*/
|
||||
|
||||
@ -62,7 +61,7 @@ Error-handling routines for HackMyResume.
|
||||
stack = ex.stack || (ex.inner && ex.inner.stack);
|
||||
stack && o(chalk.gray(stack));
|
||||
}
|
||||
if (ex.quit || objError.quit) {
|
||||
if (shouldExit) {
|
||||
if (this.debug) {
|
||||
o(chalk.cyan('Exiting with error code ' + ex.fluenterror.toString()));
|
||||
}
|
||||
@ -221,6 +220,10 @@ Error-handling routines for HackMyResume.
|
||||
msg = ex;
|
||||
}
|
||||
etype = 'error';
|
||||
break;
|
||||
case HMSTATUS.createError:
|
||||
msg = printf(M2C(this.msgs.createError.msg), ex.inner.path);
|
||||
etype = 'error';
|
||||
}
|
||||
return {
|
||||
msg: msg,
|
||||
@ -231,3 +234,5 @@ Error-handling routines for HackMyResume.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=error.js.map
|
||||
|
44
dist/cli/main.js
vendored
44
dist/cli/main.js
vendored
@ -6,7 +6,7 @@ Definition of the `main` function.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var Command, EXTEND, FS, HME, HMR, HMSTATUS, OUTPUT, PAD, PATH, PKG, StringUtils, _, _opts, _out, _title, chalk, execute, initOptions, initialize, loadOptions, logMsg, main, safeLoadJSON, splitSrcDest;
|
||||
var Command, EXTEND, FS, HME, HMR, HMSTATUS, OUTPUT, PAD, PATH, PKG, StringUtils, _, _err, _exitCallback, _opts, _out, _title, chalk, execute, initOptions, initialize, loadOptions, logMsg, main, safeLoadJSON, splitSrcDest;
|
||||
|
||||
HMR = require('../index');
|
||||
|
||||
@ -42,6 +42,10 @@ Definition of the `main` function.
|
||||
|
||||
_out = new OUTPUT(_opts);
|
||||
|
||||
_err = require('./error');
|
||||
|
||||
_exitCallback = null;
|
||||
|
||||
|
||||
/*
|
||||
A callable implementation of the HackMyResume CLI. Encapsulates the command
|
||||
@ -51,9 +55,9 @@ Definition of the `main` function.
|
||||
process.argv (in production) or custom parameters (in test).
|
||||
*/
|
||||
|
||||
main = module.exports = function(rawArgs) {
|
||||
main = module.exports = function(rawArgs, exitCallback) {
|
||||
var args, initInfo, program;
|
||||
initInfo = initialize(rawArgs);
|
||||
initInfo = initialize(rawArgs, exitCallback);
|
||||
args = initInfo.args;
|
||||
program = new Command('hackmyresume').version(PKG.version).description(chalk.yellow.bold('*** HackMyResume ***')).option('-s --silent', 'Run in silent mode').option('--no-color', 'Disable colors').option('--color', 'Enable colors').option('-d --debug', 'Enable diagnostics', false).option('-a --assert', 'Treat warnings as errors', false).option('-v --version', 'Show the version').allowUnknownOption();
|
||||
program.jsonArgs = initInfo.options;
|
||||
@ -92,8 +96,9 @@ Definition of the `main` function.
|
||||
|
||||
/* Massage command-line args and setup Commander.js. */
|
||||
|
||||
initialize = function(ar) {
|
||||
initialize = function(ar, exitCallback) {
|
||||
var o;
|
||||
_exitCallback = exitCallback || process.exit;
|
||||
o = initOptions(ar);
|
||||
o.silent || logMsg(_title);
|
||||
if (o.debug) {
|
||||
@ -105,12 +110,13 @@ Definition of the `main` function.
|
||||
_out.log(chalk.cyan(PAD(' FRESCA:', 25, null, PAD.RIGHT)) + chalk.cyan.bold(PKG.dependencies.fresca));
|
||||
_out.log('');
|
||||
}
|
||||
_err.init(o.debug, o.assert, o.silent);
|
||||
if (o.verb && !HMR.verbs[o.verb] && !HMR.alias[o.verb]) {
|
||||
throw {
|
||||
_err.err({
|
||||
fluenterror: HMSTATUS.invalidCommand,
|
||||
quit: true,
|
||||
attempted: o.orgVerb
|
||||
};
|
||||
}, true);
|
||||
}
|
||||
Command.prototype.missingArgument = function(name) {
|
||||
if (this.name() !== 'new') {
|
||||
@ -136,7 +142,7 @@ Definition of the `main` function.
|
||||
|
||||
initOptions = function(ar) {
|
||||
oVerb;
|
||||
var args, cleanArgs, inf, isDebug, isMono, isSilent, oJSON, oVerb, optStr, optsIdx, verb, vidx;
|
||||
var args, cleanArgs, inf, isAssert, isDebug, isMono, isSilent, oJSON, oVerb, optStr, optsIdx, verb, vidx;
|
||||
verb = '';
|
||||
args = ar.slice();
|
||||
cleanArgs = args.slice(2);
|
||||
@ -177,6 +183,9 @@ Definition of the `main` function.
|
||||
isSilent = _.some(args, function(v) {
|
||||
return v === '-s' || v === '--silent';
|
||||
});
|
||||
isAssert = _.some(args, function(v) {
|
||||
return v === '-a' || v === '--assert';
|
||||
});
|
||||
isMono = _.some(args, function(v) {
|
||||
return v === '--no-color';
|
||||
});
|
||||
@ -184,6 +193,7 @@ Definition of the `main` function.
|
||||
color: !isMono,
|
||||
debug: isDebug,
|
||||
silent: isSilent,
|
||||
assert: isAssert,
|
||||
orgVerb: oVerb,
|
||||
verb: verb,
|
||||
json: oJSON,
|
||||
@ -195,24 +205,22 @@ Definition of the `main` function.
|
||||
/* Invoke a HackMyResume verb. */
|
||||
|
||||
execute = function(src, dst, opts, log) {
|
||||
var hand, v;
|
||||
loadOptions.call(this, opts, this.parent.jsonArgs);
|
||||
hand = require('./error');
|
||||
hand.init(_opts.debug, _opts.assert, _opts.silent);
|
||||
var onFail, prom, v;
|
||||
v = new HMR.verbs[this.name()]();
|
||||
loadOptions.call(this, opts, this.parent.jsonArgs);
|
||||
_opts.errHandler = v;
|
||||
_out.init(_opts);
|
||||
v.on('hmr:status', function() {
|
||||
return _out["do"].apply(_out, arguments);
|
||||
});
|
||||
v.on('hmr:error', function() {
|
||||
return hand.err.apply(hand, arguments);
|
||||
return _err.err.apply(_err, arguments);
|
||||
});
|
||||
v.invoke.call(v, src, dst, _opts, log);
|
||||
if (v.errorCode) {
|
||||
console.log('Exiting with error code ' + v.errorCode);
|
||||
return process.exit(v.errorCode);
|
||||
}
|
||||
prom = v.invoke.call(v, src, dst, _opts, log);
|
||||
onFail = function(err) {
|
||||
_exitCallback(err.fluenterror ? err.fluenterror : err);
|
||||
};
|
||||
prom.then((function() {}), onFail);
|
||||
};
|
||||
|
||||
|
||||
@ -282,3 +290,5 @@ Definition of the `main` function.
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=main.js.map
|
||||
|
2
dist/cli/msg.js
vendored
2
dist/cli/msg.js
vendored
@ -15,3 +15,5 @@ Message-handling routines for HackMyResume.
|
||||
module.exports = YAML.load(PATH.join(__dirname, 'msg.yml'));
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=msg.js.map
|
||||
|
4
dist/cli/msg.yml
vendored
4
dist/cli/msg.yml
vendored
@ -3,6 +3,8 @@ events:
|
||||
msg: Invoking **%s** command.
|
||||
beforeCreate:
|
||||
msg: Creating new **%s** resume: **%s**
|
||||
afterCreate:
|
||||
msg: Creating new **%s** resume: **%s**
|
||||
afterRead:
|
||||
msg: Reading **%s** resume: **%s**
|
||||
beforeTheme:
|
||||
@ -96,3 +98,5 @@ errors:
|
||||
msg: "Invalid number of parameters. Expected: **%s**."
|
||||
missingParam:
|
||||
msg: The '**%s**' parameter was needed but not supplied.
|
||||
createError:
|
||||
msg: Failed to create **'%s'**.
|
||||
|
6
dist/cli/out.js
vendored
6
dist/cli/out.js
vendored
@ -60,8 +60,8 @@ Output routines for HackMyResume.
|
||||
switch (evt.sub) {
|
||||
case HME.begin:
|
||||
return this.opts.debug && L(M2C(this.msgs.begin.msg, dbgStyle), evt.cmd.toUpperCase());
|
||||
case HME.beforeCreate:
|
||||
L(M2C(this.msgs.beforeCreate.msg, 'green'), evt.fmt, evt.file);
|
||||
case HME.afterCreate:
|
||||
L(M2C(this.msgs.beforeCreate.msg, evt.isError ? 'red' : 'green'), evt.fmt, evt.file);
|
||||
break;
|
||||
case HME.beforeTheme:
|
||||
return this.opts.debug && L(M2C(this.msgs.beforeTheme.msg, dbgStyle), evt.theme.toUpperCase());
|
||||
@ -155,3 +155,5 @@ Output routines for HackMyResume.
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
//# sourceMappingURL=out.js.map
|
||||
|
Reference in New Issue
Block a user