@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.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { templatemarkutil } from '@accordproject/markdown-template';
|
|
|
14
14
|
import { existsSync, mkdirSync, rmSync } from 'fs';
|
|
15
15
|
import * as lzstring from 'lz-string';
|
|
16
16
|
import child_process from 'child_process';
|
|
17
|
+
import path from 'path';
|
|
17
18
|
|
|
18
19
|
function booleanDrafter(value) {
|
|
19
20
|
if (value) {
|
|
@@ -525,13 +526,22 @@ class JavaScriptEvaluator {
|
|
|
525
526
|
});
|
|
526
527
|
}
|
|
527
528
|
}
|
|
529
|
+
getWorkerPath() {
|
|
530
|
+
try {
|
|
531
|
+
const thisPath = require.resolve("@accordproject/template-engine");
|
|
532
|
+
return path.join(thisPath, "..", "worker.js");
|
|
533
|
+
} catch (err) {
|
|
534
|
+
return path.join(__dirname, "..", "dist", "worker.js");
|
|
535
|
+
}
|
|
536
|
+
}
|
|
528
537
|
doWork(work, options) {
|
|
529
538
|
return new Promise((resolve, reject) => {
|
|
530
539
|
const start = (/* @__PURE__ */ new Date()).getTime();
|
|
531
540
|
if (!child_process.fork) {
|
|
532
541
|
reject({ message: "Cannot use evalChildProcess because child_process.fork is not defined." });
|
|
533
542
|
}
|
|
534
|
-
const
|
|
543
|
+
const workerPath = this.getWorkerPath();
|
|
544
|
+
const worker = child_process.fork(workerPath, { timeout: options.timeout, env: {} });
|
|
535
545
|
if (!worker.pid) {
|
|
536
546
|
throw new Error("Failed to fork child process");
|
|
537
547
|
}
|