-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathinitLaunchSandbox.ts
More file actions
75 lines (65 loc) · 2.22 KB
/
Copy pathinitLaunchSandbox.ts
File metadata and controls
75 lines (65 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import * as cp from "node:child_process";
import { exit } from "node:process";
/**
* This script creates a VSCode settings profile for Cursorless development,
* allowing you to have a separate set of extensions and settings for use when
* developing the Cursorless VSCode extension locally.
*/
import { extensionDependencies } from "@cursorless/lib-common";
const vsCodeToolName: string = "code";
const validCliToolParams = new Set(["--code", "--codium"]);
async function main() {
try {
// Read cli tool name from arguments, assume tool name is 'code' if not present
let cliToolName = vsCodeToolName;
for (const argument of process.argv) {
if (validCliToolParams.has(argument)) {
cliToolName = argument.replace("--", "");
console.log(`Cli tool name manually set to ${cliToolName}`);
}
}
const extensions = [
...extensionDependencies,
"pokey.command-server",
"mrob95.vscode-talonscript",
];
// Do not attempt to install jrieken:vscode-tree-sitter-query if editor is NOT VSCode, assuming lack of access to VSCode Marketplace
if (cliToolName === vsCodeToolName) {
extensions.push("jrieken.vscode-tree-sitter-query");
} else {
console.log(
"Not installing jrieken:vscode-tree-sitter-query as it is not on the OpenVSX Marketplace.",
);
console.log(
"You should install this extension manually. Check the Cursorless contributor documentation for more info.",
);
}
const args = [
"--profile=cursorlessDevelopment",
...extensions.flatMap((e) => ["--install-extension", e]),
];
if (process.argv.includes("--force")) {
args.push("--force");
}
// Install extension dependencies
const subprocess = cp.spawn(cliToolName, args, {
stdio: "inherit",
shell: true,
});
await new Promise<void>((resolve, reject) => {
subprocess.on("error", reject);
subprocess.on("exit", (code) => {
if (code === 0) {
resolve();
} else {
reject(new Error(`Process returned code ${code}`));
}
});
});
} catch (error) {
console.error("Failed to init launch sandbox");
console.error(error);
exit(1);
}
}
await main();