Comparing version 0.2.3 to 0.2.4
@@ -52,2 +52,4 @@ "use strict"; | ||
var ResultTarget_1 = require("./ResultTarget"); | ||
var nightingale_logger_1 = require("nightingale-logger"); | ||
var logger = new nightingale_logger_1.default("redir:ProcessUnit"); | ||
var ProcessUnit = /** @class */ (function () { | ||
@@ -71,9 +73,12 @@ function ProcessUnit(redir, script, resultTarget) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, Promise.all([this.createVM(context), input])]; | ||
case 0: | ||
logger.debug("creating vm..."); | ||
return [4 /*yield*/, Promise.all([this.createVM(context), input])]; | ||
case 1: | ||
_a = _b.sent(), vmInstance = _a[0], inputVal = _a[1]; | ||
if (!("handle" in vmInstance)) { | ||
// debug("missing handle method!"); | ||
logger.debug("missing handle method!"); | ||
throw new Error("Expecting handle(input) method in script"); | ||
} | ||
logger.debug("handling input:", inputVal); | ||
result = vmInstance.handle(inputVal.toString()); | ||
@@ -97,3 +102,3 @@ if (typeof result === "string") { | ||
vm.runInContext(this.scriptContent, vmContext); | ||
// debug("sandbox keys:", Object.keys(sandbox)); | ||
logger.debug("sandbox keys:", Object.keys(sandbox)); | ||
return vmContext; | ||
@@ -100,0 +105,0 @@ }; |
import { Context, Output } from "./types"; | ||
export declare enum ResultTargetType { | ||
Context = 0, | ||
Output = 1 | ||
Output = 0, | ||
Context = 1 | ||
} | ||
@@ -6,0 +6,0 @@ export declare class ResultTarget { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var nightingale_logger_1 = require("nightingale-logger"); | ||
var logger = new nightingale_logger_1.default("redir:ResultTarget"); | ||
var ResultTargetType; | ||
(function (ResultTargetType) { | ||
ResultTargetType[ResultTargetType["Context"] = 0] = "Context"; | ||
ResultTargetType[ResultTargetType["Output"] = 1] = "Output"; | ||
ResultTargetType[ResultTargetType["Output"] = 0] = "Output"; | ||
ResultTargetType[ResultTargetType["Context"] = 1] = "Context"; | ||
})(ResultTargetType = exports.ResultTargetType || (exports.ResultTargetType = {})); | ||
@@ -16,7 +18,3 @@ var ResultTarget = /** @class */ (function () { | ||
if (this.type === ResultTargetType.Context) { | ||
// debug( | ||
// `Storing results of ${ | ||
// task.name | ||
// } in context as ${task.resultContextName}` | ||
// ); | ||
logger.debug("Storing results as " + this.name + " in context"); | ||
context[this.name] = result; | ||
@@ -23,0 +21,0 @@ } |
{ | ||
"name": "redir-core", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
71941
1586