@accordproject/template-engine 2.5.5 → 2.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var markdownTemplate = require('@accordproject/markdown-template');
|
|
|
16
16
|
var fs = require('fs');
|
|
17
17
|
var lzstring = require('lz-string');
|
|
18
18
|
var child_process = require('child_process');
|
|
19
|
+
var path = require('path');
|
|
19
20
|
|
|
20
21
|
function _interopNamespaceDefault(e) {
|
|
21
22
|
var n = Object.create(null);
|
|
@@ -546,13 +547,22 @@ class JavaScriptEvaluator {
|
|
|
546
547
|
});
|
|
547
548
|
}
|
|
548
549
|
}
|
|
550
|
+
getWorkerPath() {
|
|
551
|
+
try {
|
|
552
|
+
const thisPath = require.resolve("@accordproject/template-engine");
|
|
553
|
+
return path.join(thisPath, "..", "worker.js");
|
|
554
|
+
} catch (err) {
|
|
555
|
+
return path.join(__dirname, "..", "dist", "worker.js");
|
|
556
|
+
}
|
|
557
|
+
}
|
|
549
558
|
doWork(work, options) {
|
|
550
559
|
return new Promise((resolve, reject) => {
|
|
551
560
|
const start = (/* @__PURE__ */ new Date()).getTime();
|
|
552
561
|
if (!child_process.fork) {
|
|
553
562
|
reject({ message: "Cannot use evalChildProcess because child_process.fork is not defined." });
|
|
554
563
|
}
|
|
555
|
-
const
|
|
564
|
+
const workerPath = this.getWorkerPath();
|
|
565
|
+
const worker = child_process.fork(workerPath, { timeout: options.timeout, env: {} });
|
|
556
566
|
if (!worker.pid) {
|
|
557
567
|
throw new Error("Failed to fork child process");
|
|
558
568
|
}
|