mirror of
https://github.com/zhigang1992/deployd.git
synced 2026-05-22 12:33:40 +08:00
Fixed errors on script compiling
This commit is contained in:
@@ -9,14 +9,21 @@ var vm = require('vm')
|
||||
*/
|
||||
|
||||
function Script(src, path) {
|
||||
this.compiled = vm.createScript('(function() {' + src + '\n}).call(_this)', path);
|
||||
try {
|
||||
this.compiled = vm.createScript('(function() {' + src + '\n}).call(_this)', path);
|
||||
} catch(ex) {
|
||||
this.error = ex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the current script in the given sandbox. An optional domain may be provided to extend the sandbox exposed to the script.
|
||||
*/
|
||||
|
||||
Script.prototype.run = function (ctx, domain, fn) {
|
||||
Script.prototype.run = function (ctx, domain, fn) {
|
||||
|
||||
if (this.error) { fn(this.error); }
|
||||
|
||||
if(typeof domain === 'function') {
|
||||
fn = domain;
|
||||
|
||||
Reference in New Issue
Block a user