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 { getProjectRoots, parseFiles } from './shared';
|
||||||
import { YargsAffectedOptions } from './affected';
|
import { YargsAffectedOptions } from './affected';
|
||||||
import { getTouchedProjects } from './touched';
|
import { getTouchedProjects } from './touched';
|
||||||
|
import { fileExists } from '../utils/fileutils';
|
||||||
|
|
||||||
export interface YargsFormatOptions extends YargsAffectedOptions {
|
export interface YargsFormatOptions extends YargsAffectedOptions {
|
||||||
libsAndApps?: boolean;
|
libsAndApps?: boolean;
|
||||||
@ -41,7 +42,9 @@ function getPatterns(args: YargsAffectedOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const p = parseFiles(args);
|
const p = parseFiles(args);
|
||||||
let patterns = p.files.filter(f =>
|
let patterns = p.files
|
||||||
|
.filter(f => fileExists(f))
|
||||||
|
.filter(f =>
|
||||||
PRETTIER_EXTENSIONS.map(ext => '.' + ext).includes(path.extname(f))
|
PRETTIER_EXTENSIONS.map(ext => '.' + ext).includes(path.extname(f))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user