mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-31 01:25:38 -05:00
Adds support for installing azdata on Linux (#11469)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as cp from 'child_process';
|
||||
import * as sudo from 'sudo-prompt';
|
||||
import * as loc from '../localizedConstants';
|
||||
|
||||
/**
|
||||
@@ -17,7 +18,7 @@ export class ExitCodeError extends Error {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Executes the specified command. Throws an error for a non-0 exit code or if stderr receives output
|
||||
* @param command The command to execute
|
||||
* @param args Optional args to pass, every arg and arg value must be a separate item in the array
|
||||
* @param outputChannel Channel used to display diagnostic information
|
||||
@@ -42,3 +43,25 @@ export async function executeCommand(command: string, args?: string[], outputCha
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a command with admin privileges. The user will be prompted to enter credentials for invocation of
|
||||
* this function. The exact prompt is platform-dependent.
|
||||
* @param command The command to execute
|
||||
* @param args The additional args
|
||||
* @param outputChannel Channel used to display diagnostic information
|
||||
*/
|
||||
export async function executeSudoCommand(command: string, outputChannel?: vscode.OutputChannel): Promise<string> {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
outputChannel?.appendLine(loc.executingCommand(`sudo ${command}`, []));
|
||||
sudo.exec(command, { name: vscode.env.appName }, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else if (stderr) {
|
||||
reject(stderr.toString('utf8'));
|
||||
} else {
|
||||
resolve(stdout ? stdout.toString('utf8') : '');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user