MCPcopy
hub / github.com/dotnet/vscode-csharp / installExtension

Function installExtension

test/vscodeLauncher.ts:96–113  ·  view source on GitHub ↗
(extensionId: string, vscodeCli: string, vscodeArgs: string[])

Source from the content-addressed store, hash-verified

94}
95
96async function installExtension(extensionId: string, vscodeCli: string, vscodeArgs: string[]): Promise<void> {
97 const argsWithExtension = [...vscodeArgs, '--install-extension', extensionId];
98
99 // Since we're using shell execute, spaces in the CLI path will get interpeted as args
100 // Therefore we wrap the CLI path in quotes as on MacOS the path can contain spaces.
101 const cliWrapped = `"${vscodeCli}"`;
102 console.log(`${cliWrapped} ${argsWithExtension}`);
103
104 const result = cp.spawnSync(cliWrapped, argsWithExtension, {
105 encoding: 'utf-8',
106 stdio: 'inherit',
107 // Workaround as described in https://github.com/nodejs/node/issues/52554
108 shell: true,
109 });
110 if (result.error || result.status !== 0) {
111 throw new Error(`Failed to install extensions: ${JSON.stringify(result)}`);
112 }
113}
114
115function getSln(workspacePath: string): string | undefined {
116 if (workspacePath.endsWith('slnWithGenerator')) {

Callers 1

installExtensionsFunction · 0.85

Calls 1

logMethod · 0.80

Tested by

no test coverage detected