Add taskCommand

feature/ssh-config
Kelvin Schoofs 4 years ago
parent 7a4df82f20
commit 7d94bb8c7a

@ -98,6 +98,8 @@ export interface FileSystemConfig extends ConnectConfig {
sftpSudo?: string | boolean;
/** The command(s) to run when a new SSH terminal gets created. Defaults to `$SHELL`. Internally the command `cd ...` is run first */
terminalCommand?: string | string[];
/** The command(s) to run when a `ssh-shell` gets run. Defaults to the placeholder `$COMMAND`. Internally the command `cd ...` is run first */
taskCommand?: string | string[];
/** The filemode to assign to created files */
newFileMode?: number | string;
/** Whether this config was created from an instant connection string. Enables fuzzy matching for e.g. PuTTY, config-by-host, ... */

@ -283,13 +283,22 @@ export class Manager implements vscode.TaskProvider, vscode.TerminalLinkProvider
`SSH Task '${task.name}'`,
'ssh',
new vscode.CustomExecution(async (resolved: SSHShellTaskOptions) => {
const { createTerminal, createTextTerminal } = await import('./pseudoTerminal');
const { createTerminal, createTextTerminal, joinCommands } = await import('./pseudoTerminal');
try {
if (!resolved.host) throw new Error('Missing field \'host\' in task description');
if (!resolved.command) throw new Error('Missing field \'command\' in task description');
const connection = await this.connectionManager.createConnection(resolved.host);
resolved = await this.replaceTaskVariablesRecursive(resolved, value => this.replaceTaskVariables(value, connection.actualConfig));
const { command, workingDirectory } = resolved;
let { command, workingDirectory } = resolved;
let { taskCommand = '$COMMAND' } = connection.actualConfig;
taskCommand = joinCommands(taskCommand)!;
if (taskCommand.includes('$COMMAND')) {
command = taskCommand.replace(/\$COMMAND/g, command);
} else {
const message = `The taskCommand '${taskCommand}' is missing the '$COMMAND' placeholder!`;
Logging.warning(message, LOGGING_NO_STACKTRACE);
command = `echo "Missing '$COMMAND' placeholder"`;
}
//if (workingDirectory) workingDirectory = this.getRemotePath(config, workingDirectory);
this.connectionManager.update(connection, con => con.pendingUserCount++);
const pty = await createTerminal({

@ -36,7 +36,7 @@ export interface TerminalOptions {
command?: string;
}
function joinCommands(commands?: string | string[]): string | undefined {
export function joinCommands(commands?: string | string[]): string | undefined {
if (!commands) return undefined;
if (typeof commands === 'string') return commands;
return commands.join('; ');

Loading…
Cancel
Save