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

Fix PEEK command.

This commit is contained in:
hacksalot 2016-02-03 20:08:17 -05:00
parent 49ae016f08
commit 5bf4bda6de
8 changed files with 38 additions and 23 deletions

1
dist/cli/main.js vendored
View File

@ -236,7 +236,6 @@ Definition of the `main` function.
finalErrorCode = -1; finalErrorCode = -1;
if (err) { if (err) {
finalErrorCode = err.fluenterror ? err.fluenterror : err; finalErrorCode = err.fluenterror ? err.fluenterror : err;
console.log(err.stack);
} }
if (_opts.debug) { if (_opts.debug) {
msgs = require('./msg').errors; msgs = require('./msg').errors;

2
dist/cli/out.js vendored
View File

@ -147,7 +147,7 @@ Output routines for HackMyResume.
} else { } else {
L(M2C(this.msgs.beforePeek.msg[1], sty), evt.file); L(M2C(this.msgs.beforePeek.msg[1], sty), evt.file);
} }
if (evt.target !== void 0) { if (evt.target !== void 0 && !evt.error) {
return console.dir(evt.target, { return console.dir(evt.target, {
depth: null, depth: null,
colors: true colors: true

7
dist/verbs/peek.js vendored
View File

@ -52,8 +52,7 @@ Implementation of the 'peek' verb for HackMyResume.
} }
tgt = _peekOne.call(this, t, objPath); tgt = _peekOne.call(this, t, objPath);
if (tgt.error) { if (tgt.error) {
tgt.quit = opts.assert; this.setError(tgt.error.fluenterror, tgt.error);
this.err(tgt.fluenterror, tgt);
} }
return tgt; return tgt;
}, this); }, this);
@ -97,8 +96,8 @@ Implementation of the 'peek' verb for HackMyResume.
error: pkgError error: pkgError
}); });
return { return {
val: tgt, val: obj.ex ? void 0 : tgt,
errpr: pkgError error: pkgError
}; };
}; };

View File

@ -271,7 +271,6 @@ executeFail = (err) ->
finalErrorCode = -1 finalErrorCode = -1
if err if err
finalErrorCode = if err.fluenterror then err.fluenterror else err finalErrorCode = if err.fluenterror then err.fluenterror else err
console.log err.stack
if _opts.debug if _opts.debug
msgs = require('./msg').errors; msgs = require('./msg').errors;
logMsg printf M2C( msgs.exiting.msg, 'cyan' ), finalErrorCode logMsg printf M2C( msgs.exiting.msg, 'cyan' ), finalErrorCode

View File

@ -165,12 +165,12 @@ module.exports = class OutputHandler
L(M2C(this.msgs.beforePeek.msg[1], sty), evt.file) L(M2C(this.msgs.beforePeek.msg[1], sty), evt.file)
# If the key was present, print it # If the key was present, print it
if evt.target != undefined if evt.target != undefined and !evt.error
console.dir( evt.target, { depth: null, colors: true } ) console.dir( evt.target, { depth: null, colors: true } )
# If the key was not present, but no error occurred, print it # If the key was not present, but no error occurred, print it
else if !evt.error else if !evt.error
L(M2C( this.msgs.afterPeek.msg, 'yellow'), evt.requested, evt.file); L M2C( this.msgs.afterPeek.msg, 'yellow'), evt.requested, evt.file
else if evt.error else if evt.error
L( chalk.red( evt.error.inner.inner )); L chalk.red( evt.error.inner.inner )

View File

@ -31,11 +31,14 @@ _peek = ( src, dst, opts ) ->
objPath = (dst && dst[0]) || '' objPath = (dst && dst[0]) || ''
results = _.map src, ( t ) -> results = _.map src, ( t ) ->
return { } if opts.assert and @hasError() return { } if opts.assert and @hasError()
tgt = _peekOne.call @, t, objPath tgt = _peekOne.call @, t, objPath
if tgt.error if tgt.error
tgt.quit = opts.assert @setError tgt.error.fluenterror, tgt.error
@err tgt.fluenterror, tgt #tgt.error.quit = opts.assert
#@err tgt.error.fluenterror, tgt.error
tgt tgt
, @ , @
@ -56,9 +59,9 @@ _peekOne = ( t, objPath ) ->
obj = safeLoadJSON t obj = safeLoadJSON t
# Fetch the requested object path (or the entire file) # Fetch the requested object path (or the entire file)
tgt = null; tgt = null
if !obj.ex if !obj.ex
tgt = if objPath then __.get obj.json, objPath else obj.json; tgt = if objPath then __.get obj.json, objPath else obj.json
## safeLoadJSON can only return a READ error or a PARSE error ## safeLoadJSON can only return a READ error or a PARSE error
pkgError = null pkgError = null
@ -68,7 +71,6 @@ _peekOne = ( t, objPath ) ->
obj.ex.quiet = true obj.ex.quiet = true
pkgError = fluenterror: errCode, inner: obj.ex pkgError = fluenterror: errCode, inner: obj.ex
# Fire the 'afterPeek' event with collected info # Fire the 'afterPeek' event with collected info
@stat HMEVENT.afterPeek, @stat HMEVENT.afterPeek,
file: t file: t
@ -76,4 +78,5 @@ _peekOne = ( t, objPath ) ->
target: if obj.ex then undefined else tgt target: if obj.ex then undefined else tgt
error: pkgError error: pkgError
val: tgt, errpr: pkgError val: if obj.ex then undefined else tgt
error: pkgError

View File

@ -19,16 +19,23 @@
3|peek 3|peek
14|peek doesnt-exist.json 14|peek doesnt-exist.json
14|peek doesnt-exist.json not.a.path 14|peek doesnt-exist.json not.a.path
15|peek node_modules/fresh-test-resumes/src/fresh/johnny-trouble.broken.json
0|peek test/resumes/jrs-0.0.0/richard-hendriks.json work[0] 0|peek test/resumes/jrs-0.0.0/richard-hendriks.json work[0]
0|peek node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json employment.history[1] 0|peek node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json employment.history[1]
0|peek node_modules/fresh-test-resumes/src/fresh/johnny-trouble.json skills.sets 0|peek node_modules/fresh-test-resumes/src/fresh/johnny-trouble.json skills.sets
3|build 3|build
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json test/sandbox/cli-test/jane/resume.html 0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.all
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json test/sandbox/cli-test/jane/resume.pdf 0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.html
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json test/sandbox/cli-test/jane/resume.md 0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.pdf
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json test/sandbox/cli-test/jane/resume.txt 0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.md
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json test/sandbox/cli-test/jane/resume.yml 0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.txt
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json test/sandbox/cli-test/jane/resume.json 0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.yml
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.json
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.all --theme modern
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.all --theme compact
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.all --theme positive
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.all --theme basis
0|build node_modules/fresh-test-resumes/src/fresh/jane-fullstacker.json TO test/sandbox/cli-test/jane/resume.all --theme awesome
14|build doesnt-exist.json 14|build doesnt-exist.json
14|build doesnt-exist.json -t not-a-theme 14|build doesnt-exist.json -t not-a-theme
14|build doesnt-exist.json -t node_modules/not-a-theme 14|build doesnt-exist.json -t node_modules/not-a-theme

View File

@ -37,7 +37,15 @@ function genThemes( title, src, fmt ) {
}; };
try { try {
var v = new HMR.verbs.build(); var v = new HMR.verbs.build();
v.invoke( src, dst, opts ); var p = v.invoke( src, dst, opts );
p.then(
function(obj){
},
function(obj){
throw obj;
}
);
} }
catch(ex) { catch(ex) {
console.error( ex ); console.error( ex );