From: pxysource Date: Mon, 9 Sep 2024 13:35:09 +0000 (+0800) Subject: FIX #73, cd command need '/d' option on Windows (cmd.exe). (#74) X-Git-Url: https://repo.jachan.dev/pico-vscode.git/commitdiff_plain/e9d54656cd606a5780034997aa0894f27f522a3d FIX #73, cd command need '/d' option on Windows (cmd.exe). (#74) --- diff --git a/src/utils/examplesUtil.mts b/src/utils/examplesUtil.mts index 791e666..9498774 100644 --- a/src/utils/examplesUtil.mts +++ b/src/utils/examplesUtil.mts @@ -174,7 +174,9 @@ export async function setupExample( if (existsSync(joinPosix(examplesRepoPath, ".git"))) { const ref = await execAsync( - `cd "${examplesRepoPath}" && ${ + `cd ${ + process.env.ComSpec?.endsWith("cmd.exe") ? "/d " : " " + }"${examplesRepoPath}" && ${ process.env.ComSpec === "powershell.exe" ? "&" : "" }"${gitPath}" rev-parse HEAD` ); diff --git a/src/utils/gitUtil.mts b/src/utils/gitUtil.mts index dbc3da1..ed5f2ba 100644 --- a/src/utils/gitUtil.mts +++ b/src/utils/gitUtil.mts @@ -55,8 +55,11 @@ export async function initSubmodules( ): Promise { try { // Use the "git submodule update --init" command in the specified directory + // `cd` command need '/d' option on Windows. (Change drive "d:\" to "c:\") const command = - `cd "${sdkDirectory}" && ` + + `cd ${ + process.env.ComSpec?.endsWith("cmd.exe") ? "/d " : " " + }"${sdkDirectory}" && ` + `${ process.env.ComSpec === "powershell.exe" ? "&" : "" }"${gitExecutable}" submodule update --init`; @@ -123,7 +126,9 @@ export async function sparseCloneRepository( try { await execAsync(cloneCommand); await execAsync( - `cd "${targetDirectory}" && ${ + `cd ${ + process.env.ComSpec?.endsWith("cmd.exe") ? "/d " : " " + }"${targetDirectory}" && ${ process.env.ComSpec === "powershell.exe" ? "&" : "" }"${gitExecutable}" sparse-checkout set --cone` ); @@ -165,7 +170,9 @@ export async function sparseCheckout( ): Promise { try { await execAsync( - `cd "${repoDirectory}" && ${ + `cd ${ + process.env.ComSpec?.endsWith("cmd.exe") ? "/d " : " " + } "${repoDirectory}" && ${ process.env.ComSpec === "powershell.exe" ? "&" : "" }"${gitExecutable}" sparse-checkout add ${checkoutPath}` );