An experimental TypeSpec syntax for Lexicon

Fix CLI on Windows #7

npm generates shims with .cmd extension on Windows, so this needs to be accounted for in the CLI scripts.

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:nmc77zslrwafxn75j66mep6o/sh.tangled.repo.pull/3mewojwaeut22
+9 -3
Diff #0
+3 -1
packages/cli/src/commands/compile.ts
··· 51 51 } 52 52 53 53 return new Promise((resolve, reject) => { 54 - const tsp = spawn("tsp", args, { 54 + const isWindows = /^win/.test(process.platform); 55 + const tsp = spawn(isWindows ? 'tsp.cmd' : 'tsp', args, { 55 56 cwd, 56 57 stdio: "inherit", 58 + shell: isWindows 57 59 }); 58 60 59 61 tsp.on("close", (code) => {
+6 -2
packages/cli/src/commands/init.ts
··· 115 115 dir = resolve(dir, ".."); 116 116 } 117 117 118 + const isWindows = /^win/.test(process.platform); 119 + 118 120 // Install dependencies 119 121 await new Promise<void>((resolvePromise, reject) => { 120 122 const args = ··· 130 132 // Add any additional flags 131 133 args.push(...flags); 132 134 133 - const install = spawn(packageManager, args, { 135 + const install = spawn(isWindows? `${packageManager}.cmd` : packageManager, args, { 134 136 cwd: projectRoot, 135 137 stdio: "inherit", 138 + shell: isWindows 136 139 }); 137 140 138 141 install.on("close", (code) => { ··· 169 172 170 173 return new Promise((resolvePromise, reject) => { 171 174 const localCli = resolve(nodeModulesDir, ".bin/typelex"); 172 - const setup = spawn(localCli, ["init", "--setup"], { 175 + const setup = spawn(isWindows ? `${localCli}.cmd` : localCli, ["init", "--setup"], { 173 176 cwd: projectRoot, 174 177 stdio: "inherit", 178 + shell: isWindows 175 179 }); 176 180 177 181 setup.on("close", (code) => {

History

1 round 0 comments
sign up or login to add to the discussion
1 commit
expand
Fix CLI on Windows
no conflicts, ready to merge
expand 0 comments