Skip to content

Commit

Permalink
fix(misc): format must exclude ignored patterns (nrwl#18568)
Browse files Browse the repository at this point in the history
`nx format` commands will now correctly ignore
patterns defined in `.gitignore` or `.nxignore`
  • Loading branch information
Stefano Pongelli committed Aug 17, 2023
1 parent 2034cdd commit 6785ef8
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 @@ -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

0 comments on commit 6785ef8

Please sign in to comment.