Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(misc): format must exclude ignored patterns #18670

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/nx/src/command-line/format/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
parseFiles,
splitArgsIntoNxArgsAndOverrides,
} from '../../utils/command-line-utils';
import { getIgnoreObject } from '../../utils/ignore';
import { fileExists, readJsonFile, writeJsonFile } from '../../utils/fileutils';
import { calculateFileChanges, FileData } from '../../project-graph/file-utils';
import * as yargs from 'yargs';
Expand Down Expand Up @@ -94,9 +95,16 @@ async function getPatterns(
(f) => fileExists(f) && supportedExtensions.includes(path.extname(f))
);

// exclude patterns in .nxignore or .gitignore
const nonIgnoredPatterns = getIgnoreObject().filter(patterns);

return args.libsAndApps
? await getPatternsFromApps(patterns, await allFileData(), graph)
: patterns;
? await getPatternsFromApps(
nonIgnoredPatterns,
await allFileData(),
graph
)
: nonIgnoredPatterns;
} catch {
return allFilesPattern;
}
Expand Down