Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/unixTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ 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');
// String.prototype.replace matches the first occurrence, so when helperPath
// already contains 'app.asar.unpacked' (e.g. a caller of node-pty that
// itself lives in app.asar.unpacked) the substring 'app.asar' matches the
// prefix of 'app.asar.unpacked' and we'd produce 'app.asar.unpacked.unpacked'
// — a path that doesn't exist on disk. Skip each rewrite if the unpacked
// variant is already present.
if (helperPath.indexOf('app.asar.unpacked') === -1) {
helperPath = helperPath.replace('app.asar', 'app.asar.unpacked');
}
if (helperPath.indexOf('node_modules.asar.unpacked') === -1) {
helperPath = helperPath.replace('node_modules.asar', 'node_modules.asar.unpacked');
}

const DEFAULT_FILE = 'sh';
const DEFAULT_NAME = 'xterm';
Expand Down