fix(build): validate packaged spawn helpers

This commit is contained in:
Tianyi Cui
2026-07-29 21:49:21 +08:00
parent 98e6a0573f
commit 7b1e8978a9
12 changed files with 167 additions and 20 deletions

View File

@@ -2,7 +2,7 @@ diff --git a/lib/unixTerminal.js b/lib/unixTerminal.js
index 1ec12f796a822c78fba9ad7f6448c3987e325c23..5cd6b7d635f4752be5a6c5ff9cf9edf988cf94c5 100644
--- a/lib/unixTerminal.js
+++ b/lib/unixTerminal.js
@@ -26,10 +26,22 @@ var terminal_1 = require("./terminal");
@@ -26,10 +26,23 @@ var terminal_1 = require("./terminal");
var utils_1 = require("./utils");
var native = utils_1.loadNativeModule('pty');
var pty = native.module;
@@ -10,6 +10,7 @@ index 1ec12f796a822c78fba9ad7f6448c3987e325c23..5cd6b7d635f4752be5a6c5ff9cf9edf9
-helperPath = path.resolve(__dirname, helperPath);
-helperPath = helperPath.replace('app.asar', 'app.asar.unpacked');
-helperPath = helperPath.replace('node_modules.asar', 'node_modules.asar.unpacked');
+// A current external embedded-runtime consumer supplies a non-sibling helper.
+var helperPath = process.env.DSH_NODE_PTY_SPAWN_HELPER;
+if (helperPath) {
+ helperPath = path.resolve(helperPath);
@@ -33,7 +34,7 @@ diff --git a/src/unixTerminal.ts b/src/unixTerminal.ts
index 98733dc0cd752b554bd94e45904ca341ad141bba..fa234291206617ae5a6d8605abf9771220392d17 100644
--- a/src/unixTerminal.ts
+++ b/src/unixTerminal.ts
@@ -14,10 +14,20 @@ import { assign, loadNativeModule } from './utils';
@@ -14,10 +14,21 @@ import { assign, loadNativeModule } from './utils';
const native = loadNativeModule('pty');
const pty: IUnixNative = native.module;
@@ -41,6 +42,7 @@ index 98733dc0cd752b554bd94e45904ca341ad141bba..fa234291206617ae5a6d8605abf97712
-helperPath = path.resolve(__dirname, helperPath);
-helperPath = helperPath.replace('app.asar', 'app.asar.unpacked');
-helperPath = helperPath.replace('node_modules.asar', 'node_modules.asar.unpacked');
+// A current external embedded-runtime consumer supplies a non-sibling helper.
+let helperPath = process.env.DSH_NODE_PTY_SPAWN_HELPER;
+if (helperPath) {
+ helperPath = path.resolve(helperPath);