Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
fix: Make console unavailable in sandbox hooks under node >= 8
Browse files Browse the repository at this point in the history
Addressing apiaryio/pitboss#13
Close #754
  • Loading branch information
honzajavorek committed Jan 18, 2018
1 parent 2b2eba3 commit 23b3927
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/transaction-runner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ class TransactionRunner

sandboxedWrappedCode: (hookCode) ->
return """
// make console unavailable
try {
// node >= 8
console = undefined;
} catch (_exc) {
// node < 8
var console = undefined;
}
// run the hook
var log = _log.bind(null, _logs);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/transaction-runner-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2468,5 +2468,5 @@ describe 'TransactionRunner', ->
"""
runner.runHook hook, {}, (err) ->
assert.isDefined err
assert.include err, 'console'
assert.include err, 'Cannot read property \'log\' of undefined'
done()

0 comments on commit 23b3927

Please sign in to comment.