postman-sandbox
Advanced tools
Comparing version 0.0.1-beta.3 to 0.0.1-beta.4
@@ -12,2 +12,3 @@ var _ = require('lodash'), | ||
this.executing = {}; | ||
this.debug = Boolean(options && options.debug); | ||
@@ -56,8 +57,16 @@ UniversalVM.call(this, options, function (err, context) { | ||
*/ | ||
execute: function (code, options, callback) { | ||
execute: function (code, options, data, callback) { | ||
if (_.isFunction(options) && !callback) { | ||
callback = options; | ||
options = null; | ||
data = null; | ||
} | ||
if (_.isFunction(data) && !callback) { | ||
callback = data; | ||
data = null; | ||
} | ||
!_.isObject(options) && (options = {}); | ||
!_.isObject(data) && (data = {}); | ||
options.debug = this.debug; | ||
@@ -81,3 +90,3 @@ var id = uuid(), | ||
// send the code to the sendbox to be intercepted and executed | ||
this.dispatch('execute', id, code, _.omit(options, 'data'), _.get(options, 'data', {})); | ||
this.dispatch('execute', id, code, options, data); | ||
}, | ||
@@ -84,0 +93,0 @@ |
var Scope = require('uniscope'), | ||
postmanLegacyInterface = require('./postman-legacy-interface'); | ||
postmanLegacyInterface = require('./postman-legacy-interface'), | ||
PostmanConsole = require('./console'); | ||
module.exports = { | ||
listener: function (prefix) { | ||
listener: function (prefix, console) { | ||
/** | ||
@@ -11,2 +12,3 @@ * @param {String} id | ||
* @param {String} options.scriptType // @todo make sdk event | ||
* @param {Object} options.cursor | ||
* @param {Object} data | ||
@@ -28,9 +30,10 @@ * @param {Object~VariableScope} data.globals | ||
var bridge = this, | ||
legacyInterface = postmanLegacyInterface.create(_.pick(options, 'scriptType'), _.get(data, 'legacy')), | ||
cursor = options.cursor || {}, | ||
scope = Scope.create({ | ||
console: options.debug, | ||
eval: true | ||
}, { | ||
postman: legacyInterface | ||
}), | ||
}, _.merge(_.clone(data), { | ||
postman: postmanLegacyInterface.create(_.pick(options, 'scriptType'), data), | ||
console: new PostmanConsole(bridge, cursor, console) | ||
})), | ||
dispatchEventName = prefix + id, | ||
@@ -43,3 +46,7 @@ done = (function (dispatchEventName) { | ||
sealed = true; | ||
bridge.dispatch(dispatchEventName, err || null); | ||
if (err) { | ||
return bridge.dispatch(dispatchEventName, err); | ||
} | ||
bridge.dispatch(dispatchEventName, null, data); | ||
}; | ||
@@ -46,0 +53,0 @@ }(dispatchEventName)); |
@@ -38,3 +38,3 @@ /**! | ||
bridge.on('ping', require('./ping').listener('pong')); | ||
bridge.on('execute', require('./execute').listener('execution.', this)); | ||
bridge.on('execute', require('./execute').listener('execution.', typeof console !== 'undefined' ? console : null)); | ||
@@ -41,0 +41,0 @@ // cleanup globals. nothing else should need bridge or require |
{ | ||
"name": "postman-sandbox", | ||
"version": "0.0.1-beta.3", | ||
"version": "0.0.1-beta.4", | ||
"description": "Sandbox for Postman Scripts to run in NodeJS or Chrome", | ||
@@ -85,5 +85,5 @@ "main": "index.js", | ||
"tv4": "1.2.7", | ||
"uniscope": "0.1.0-beta.2", | ||
"uniscope": "0.1.0-beta.3", | ||
"xml2js": "0.4.17" | ||
} | ||
} |
describe('sandbox', function () { | ||
this.timeout(1000 * 60); // set 60s timeout | ||
this.timeout(1000 * 60); | ||
var Sandbox = require('../../lib'); | ||
@@ -4,0 +4,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6183858
47
9336
0