Skip to content

Commit

Permalink
fix(misc): format must exclude ignored patterns (#18670)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Pongelli <[email protected]>
(cherry picked from commit c479a54)
  • Loading branch information
pongells authored and FrozenPandaz committed Aug 23, 2023
1 parent 42e2141 commit 0d4e654
Showing 1 changed file with 10 additions and 2 deletions.
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 @@ -92,9 +93,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

0 comments on commit 0d4e654

Please sign in to comment.