Files
azuredatastudio/extensions/git-ui/src/main.ts
Aditya Bist ebe835ec99 Remote CLI fixes (#15117) (#15125)
* fixes from vscode

* update distro

* fix distro

* fix hygiene

* reorder hygiene

* Update distro

Co-authored-by: chgagnon <chgagnon@microsoft.com>
(cherry picked from commit 1b78008258)
2021-04-13 21:15:22 -07:00

59 lines
1.7 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtensionContext, commands } from 'vscode';
import * as cp from 'child_process';
export async function deactivate(): Promise<any> {
}
export async function activate(context: ExtensionContext): Promise<void> {
context.subscriptions.push(commands.registerCommand('git.credential', async (_data: any) => {
return { stdout: '', stderr: '', code: 0 };
// try {
// const { stdout, stderr } = await exec(`git credential ${data.command}`, {
// stdin: data.stdin,
// env: Object.assign(process.env, { GIT_TERMINAL_PROMPT: '0' })
// });
// return { stdout, stderr, code: 0 };
// } catch ({ stdout, stderr, error }) {
// const code = error.code || 0;
// if (stderr.indexOf('terminal prompts disabled') !== -1) {
// stderr = '';
// }
// return { stdout, stderr, code };
// }
}));
}
export interface ExecResult {
error: Error | null;
stdout: string;
stderr: string;
}
export function exec(command: string, options: cp.ExecOptions & { stdin?: string } = {}) {
return new Promise<ExecResult>((resolve, reject) => {
const child = cp.exec(command, options, (error, stdout, stderr) => {
(error ? reject : resolve)({ error, stdout, stderr });
});
if (options.stdin) {
child.stdin!.write(options.stdin, (err: any) => {
if (err) {
reject(err);
return;
}
child.stdin!.end((err: any) => {
if (err) {
reject(err);
}
});
});
}
});
}