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:
ZachJW34 2019-02-19 11:40:57 -06:00 committed by Jason Jean
parent 36b8ff9c94
commit dd52f3cdca

View File

@ -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,7 +42,9 @@ function getPatterns(args: YargsAffectedOptions) {
}
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))
);