1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-03 04:47:07 +01: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

View File

@ -271,7 +271,6 @@ executeFail = (err) ->
finalErrorCode = -1
if err
finalErrorCode = if err.fluenterror then err.fluenterror else err
console.log err.stack
if _opts.debug
msgs = require('./msg').errors;
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)
# 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 } )
# If the key was not present, but no error occurred, print it
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
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]) || ''
results = _.map src, ( t ) ->
return { } if opts.assert and @hasError()
tgt = _peekOne.call @, t, objPath
if tgt.error
tgt.quit = opts.assert
@err tgt.fluenterror, tgt
@setError tgt.error.fluenterror, tgt.error
#tgt.error.quit = opts.assert
#@err tgt.error.fluenterror, tgt.error
tgt
, @
@ -56,9 +59,9 @@ _peekOne = ( t, objPath ) ->
obj = safeLoadJSON t
# Fetch the requested object path (or the entire file)
tgt = null;
tgt = null
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
pkgError = null
@ -68,7 +71,6 @@ _peekOne = ( t, objPath ) ->
obj.ex.quiet = true
pkgError = fluenterror: errCode, inner: obj.ex
# Fire the 'afterPeek' event with collected info
@stat HMEVENT.afterPeek,
file: t
@ -76,4 +78,5 @@ _peekOne = ( t, objPath ) ->
target: if obj.ex then undefined else tgt
error: pkgError
val: tgt, errpr: pkgError
val: if obj.ex then undefined else tgt
error: pkgError