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,23 @@ var terminal_1 = require("./terminal"); var utils_1 = require("./utils"); var native = utils_1.loadNativeModule('pty'); var pty = native.module; -var helperPath = native.dir + '/spawn-helper'; -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); +} +else { + var executableSibling = process.execPath + '-spawn-helper'; + if (fs.existsSync(executableSibling)) { + helperPath = executableSibling; + } + else { + helperPath = native.dir + '/spawn-helper'; + helperPath = path.resolve(__dirname, helperPath); + helperPath = helperPath.replace('app.asar', 'app.asar.unpacked'); + helperPath = helperPath.replace('node_modules.asar', 'node_modules.asar.unpacked'); + } +} var DEFAULT_FILE = 'sh'; var DEFAULT_NAME = 'xterm'; var DESTROY_SOCKET_TIMEOUT_MS = 200; 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,21 @@ import { assign, loadNativeModule } from './utils'; const native = loadNativeModule('pty'); const pty: IUnixNative = native.module; -let helperPath = native.dir + '/spawn-helper'; -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); +} else { + const executableSibling = process.execPath + '-spawn-helper'; + if (fs.existsSync(executableSibling)) { + helperPath = executableSibling; + } else { + helperPath = native.dir + '/spawn-helper'; + helperPath = path.resolve(__dirname, helperPath); + helperPath = helperPath.replace('app.asar', 'app.asar.unpacked'); + helperPath = helperPath.replace('node_modules.asar', 'node_modules.asar.unpacked'); + } +} const DEFAULT_FILE = 'sh'; const DEFAULT_NAME = 'xterm';