Skip to content

Commit

Permalink
fix(core): replace require(path/posix) for better node compatibility …
Browse files Browse the repository at this point in the history
…range (#15307)
  • Loading branch information
AgentEnder authored Feb 27, 2023
1 parent 22970b8 commit 1975181
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/nx/src/utils/ignore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFileSync } from 'fs-extra';
import ignore from 'ignore';
import { join } from 'path/posix';
import { readFileIfExisting } from './fileutils';
import { joinPathFragments } from './path';
import { workspaceRoot } from './workspace-root';

/**
Expand All @@ -18,19 +18,23 @@ export function getIgnoredGlobs(
if (prependRoot) {
return [
...getAlwaysIgnore(root),
...files.flatMap((f) => getIgnoredGlobsFromFile(join(root, f), root)),
...files.flatMap((f) =>
getIgnoredGlobsFromFile(joinPathFragments(root, f), root)
),
];
} else {
return [
...getAlwaysIgnore(),
...files.flatMap((f) => getIgnoredGlobsFromFile(join(root, f))),
...files.flatMap((f) =>
getIgnoredGlobsFromFile(joinPathFragments(root, f))
),
];
}
}

export function getAlwaysIgnore(root?: string) {
const paths = ['node_modules', '**/node_modules', '.git'];
return root ? paths.map((x) => join(root, x)) : paths;
return root ? paths.map((x) => joinPathFragments(root, x)) : paths;
}

export function getIgnoreObject(root: string = workspaceRoot) {
Expand All @@ -51,9 +55,9 @@ function getIgnoredGlobsFromFile(file: string, root?: string): string[] {
continue;
} else if (trimmed.startsWith('/')) {
if (root) {
results.push(join(root, trimmed));
results.push(joinPathFragments(root, trimmed));
} else {
results.push(join('.', trimmed));
results.push(joinPathFragments('.', trimmed));
}
} else {
results.push(trimmed);
Expand Down

1 comment on commit 1975181

@vercel
Copy link

@vercel vercel bot commented on 1975181 Feb 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.