Ignore .git, .svn and .hg directories (#4906)

Fixes #4895
master
Lucas Azzola 2018-07-30 00:08:51 +10:00 committed by GitHub
parent 440ab4f60b
commit a938076ae5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 1 deletions

View File

@ -399,10 +399,12 @@ function createIgnorerFromContextOrDie(context) {
}
function eachFilename(context, patterns, callback) {
// The '!./' globs are due to https://github.com/prettier/prettier/issues/2110
const ignoreNodeModules = context.argv["with-node-modules"] !== true;
if (ignoreNodeModules) {
patterns = patterns.concat(["!**/node_modules/**", "!./node_modules/**"]);
}
patterns = patterns.concat(["!**/.{git,svn,hg}/**", "!./.{git,svn,hg}/**"]);
try {
const filePaths = globby

View File

@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ignores files in version control systems (stderr) 1`] = `""`;
exports[`ignores files in version control systems (stdout) 1`] = `
"file.js
"
`;
exports[`ignores files in version control systems (write) 1`] = `Array []`;

View File

@ -72,7 +72,7 @@ directory/nested-directory/nested-directory-file.js
exports[`multiple patterns with non exists pattern (write) 1`] = `Array []`;
exports[`multiple patterns, throw error and exit with non zero code on non existing files (stderr) 1`] = `
"[error] No matching files. Patterns tried: non-existent.js other-non-existent.js !**/node_modules/** !./node_modules/**
"[error] No matching files. Patterns tried: non-existent.js other-non-existent.js !**/node_modules/** !./node_modules/** !**/.{git,svn,hg}/** !./.{git,svn,hg}/**
"
`;

View File

@ -0,0 +1,16 @@
"use strict";
const runPrettier = require("../runPrettier");
expect.addSnapshotSerializer(require("../path-serializer"));
describe("ignores files in version control systems", () => {
runPrettier("cli/ignore-vcs-files", [
".svn/file.js",
".hg/file.js",
"file.js",
"-l"
]).test({
status: 1
});
});

View File

@ -0,0 +1 @@
'use strict';

View File

@ -0,0 +1,2 @@
/* eslint-disable */
'use strict';

View File

@ -0,0 +1 @@
'use strict';