Skip to content

Commit

Permalink
fix(core): do not remove drive letter if running from a temp director…
Browse files Browse the repository at this point in the history
…y on windows
  • Loading branch information
Cammisuli committed Aug 21, 2023
1 parent b309d83 commit 7549766
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/devkit/src/utils/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@ export function ensurePackage<T extends any = any>(
dir: dirSync().name,
};

// check if the platform is windows, and if the drive letters of the temp directory and current directory match
// if the drive letters do not match, we need to make sure that we do not remove the letter while trying to generate files
if (process.platform == 'win32' && (tempDir[0] !== process.cwd[0])) {
process.env.NX_WINDOWS_DRIVE_LETTERS_MISMATCH = 'true';
}

console.log(`Fetching ${pkg}...`);
const packageManager = detectPackageManager();
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
Expand Down
5 changes: 5 additions & 0 deletions packages/nx/src/utils/path.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as path from 'path';

function removeWindowsDriveLetter(osSpecificPath: string): string {
// This process is running from a temp directory (which is normally on C:) while the cwd is on a different drive letter
// do not remove the drive letter in this scenario
if (process.env.NX_WINDOWS_DRIVE_LETTERS_MISMATCH === 'true') {
return osSpecificPath;
}
return osSpecificPath.replace(/^[A-Z]:/, '');
}

Expand Down

0 comments on commit 7549766

Please sign in to comment.