Archived
1
0

Add flag to install an extension from the command line (#504)

This commit is contained in:
Asher
2019-04-17 16:30:50 -05:00
committed by Kyle Carberry
parent c4c26058ef
commit 630ccfcacc
5 changed files with 53 additions and 12 deletions

View File

@ -82,7 +82,6 @@ export const requireModule = (modulePath: string, builtInExtensionsDir: string):
* @param modulePath Path of the VS Code module to load.
*/
export const forkModule = (modulePath: string, args?: string[], options?: cp.ForkOptions, dataDir?: string): cp.ChildProcess => {
let proc: cp.ChildProcess;
const forkOptions: cp.ForkOptions = {
stdio: [null, null, null, "ipc"],
};
@ -91,18 +90,27 @@ export const forkModule = (modulePath: string, args?: string[], options?: cp.For
delete options.env.ELECTRON_RUN_AS_NODE;
forkOptions.env = options.env;
}
const forkArgs = ["--bootstrap-fork", modulePath];
if (args) {
forkArgs.push("--extra-args", JSON.stringify(args));
}
if (dataDir) {
forkArgs.push("--data-dir", dataDir);
forkArgs.push("--user-data-dir", dataDir);
}
const nodeArgs = [];
if (isCli) {
proc = cp.spawn(process.execPath, [path.join(buildDir, "out", "cli.js"), ...forkArgs], forkOptions);
nodeArgs.push(path.join(buildDir, "out", "cli.js"));
} else {
proc = cp.spawn(process.execPath, ["--require", "ts-node/register", "--require", "tsconfig-paths/register", process.argv[1], ...forkArgs], forkOptions);
nodeArgs.push(
"--require", "ts-node/register",
"--require", "tsconfig-paths/register",
process.argv[1],
);
}
const proc = cp.spawn(process.execPath, [...nodeArgs, ...forkArgs], forkOptions);
if (args && args[0] === "--type=watcherService" && os.platform() === "linux") {
cp.exec(`renice -n 19 -p ${proc.pid}`, (error) => {
if (error) {