Skip to content

Commit

Permalink
FIX #73, cd command need '/d' option on Windows (cmd.exe). (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
pxysource authored Sep 9, 2024
1 parent b4aec6d commit e9d5465
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/utils/examplesUtil.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
);
Expand Down
13 changes: 10 additions & 3 deletions src/utils/gitUtil.mts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ export async function initSubmodules(
): Promise<boolean> {
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`;
Expand Down Expand Up @@ -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`
);
Expand Down Expand Up @@ -165,7 +170,9 @@ export async function sparseCheckout(
): Promise<boolean> {
try {
await execAsync(
`cd "${repoDirectory}" && ${
`cd ${
process.env.ComSpec?.endsWith("cmd.exe") ? "/d " : " "
} "${repoDirectory}" && ${
process.env.ComSpec === "powershell.exe" ? "&" : ""
}"${gitExecutable}" sparse-checkout add ${checkoutPath}`
);
Expand Down

0 comments on commit e9d5465

Please sign in to comment.