Skip to content

Commit

Permalink
chore: cleanup rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
caoxiemeihao committed Jan 8, 2024
1 parent 6d3103a commit 65eea3e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/plugin/vite/src/util/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface SourceAndDestination {
dest: string;
}

function isRootDirectory(dir: string) {
function isRootPath(dir: string) {
// Linux or Windows root path
return dir === '/' || /^[A-Z]:\\$/i.test(dir);
}
Expand All @@ -30,7 +30,7 @@ export async function lookupNodeModulesPaths(root: string, paths: string[] = [])
}
root = path.join(root, '..');

return isRootDirectory(root) ? paths : await lookupNodeModulesPaths(root, paths);
return isRootPath(root) ? paths : await lookupNodeModulesPaths(root, paths);
}

export async function readPackageJson(root = process.cwd()): Promise<PackageJsonManifest> {
Expand All @@ -57,7 +57,7 @@ export async function resolveDependencies(root: string) {
let curPath = prePath,
depPath = null,
packageJson = null;
while (!packageJson && !isRootDirectory(curPath)) {
while (!packageJson && !isRootPath(curPath)) {
const allNodeModules = await lookupNodeModulesPaths(curPath);

for (const nodeModules of allNodeModules) {
Expand Down

0 comments on commit 65eea3e

Please sign in to comment.