Disable auto-cd when ${workingDirectory} is present (#323)

pull/373/head
Kelvin Schoofs 3 years ago
parent ddfafd5b4b
commit 749a61191e

@ -13,6 +13,8 @@
- Small improvements to Dropdown(WithInput) UI components
- Delay and wait for loadConfigs() after logging version info
- This solves a small issue/annoyance where logs regarding loading logs appear before the version logging
- When `${workingDirectory}` is present in a terminal command, the extension doesn't auto-`cd` anymore
- Normally the extension runs `cd <workingDirectory>; <terminalCommand>` or similar
### Development changes
- Added `semver` as dependency in preparation of `FS_NOTIFY_ERRORS` flag

@ -193,7 +193,11 @@ export async function createTerminal(options: TerminalOptions): Promise<SSHPseud
// There isn't a proper way of setting the working directory, but this should work in most cases
let { workingDirectory } = options;
workingDirectory = workingDirectory || actualConfig.root;
let cmd = joinCommands(commands, separator)!;
if (workingDirectory) {
if (cmd.includes('${workingDirectory}')) {
cmd = cmd.replace(/\${workingDirectory}/g, workingDirectory);
} else {
// TODO: Maybe replace with `connection.home`?
if (workingDirectory.startsWith('~')) {
// So `cd "~/a/b/..." apparently doesn't work, but `~/"a/b/..."` does
@ -202,11 +206,12 @@ export async function createTerminal(options: TerminalOptions): Promise<SSHPseud
} else {
workingDirectory = `"${workingDirectory}"`;
}
commands.unshift(`cd ${workingDirectory}`);
cmd = joinCommands([`cd ${workingDirectory}`, ...commands], separator)!;
}
} else {
cmd = cmd.replace(/\${workingDirectory}/g, '');
}
const pseudoTtyOptions: PseudoTtyOptions = { ...PSEUDO_TTY_OPTIONS, cols: dims?.columns, rows: dims?.rows };
let cmd = joinCommands(commands, separator)!;
cmd = cmd.replace(/\${workingDirectory}/g, workingDirectory || '');
Logging.debug(`Starting shell for ${connection.actualConfig.name}: ${cmd}`);
const channel = await toPromise<ClientChannel | undefined>(cb => client.exec(cmd, { pty: pseudoTtyOptions }, cb));
if (!channel) throw new Error('Could not create remote terminal');

Loading…
Cancel
Save