fix(nx): filter non-existing files during format (#1087)
Formatting of uncommitted files errors when the only change is the deletion of files. Checking if the file exists before writing solves this issue.
This commit is contained in:
parent
36b8ff9c94
commit
dd52f3cdca
@ -4,6 +4,7 @@ import * as resolve from 'resolve';
|
||||
import { getProjectRoots, parseFiles } from './shared';
|
||||
import { YargsAffectedOptions } from './affected';
|
||||
import { getTouchedProjects } from './touched';
|
||||
import { fileExists } from '../utils/fileutils';
|
||||
|
||||
export interface YargsFormatOptions extends YargsAffectedOptions {
|
||||
libsAndApps?: boolean;
|
||||
@ -41,9 +42,11 @@ function getPatterns(args: YargsAffectedOptions) {
|
||||
}
|
||||
|
||||
const p = parseFiles(args);
|
||||
let patterns = p.files.filter(f =>
|
||||
PRETTIER_EXTENSIONS.map(ext => '.' + ext).includes(path.extname(f))
|
||||
);
|
||||
let patterns = p.files
|
||||
.filter(f => fileExists(f))
|
||||
.filter(f =>
|
||||
PRETTIER_EXTENSIONS.map(ext => '.' + ext).includes(path.extname(f))
|
||||
);
|
||||
|
||||
const libsAndApp = args.libsAndApps;
|
||||
return libsAndApp ? getPatternsFromApps(patterns) : patterns;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user