fix(prettierignore): support absolute filename (#2783)

This commit is contained in:
长天之云 authored and Simon Lydell committed 2017-09-10 18:21:56 +02:00
1 parent 8b02f702d5
commit df5482008e
7 files changed
+35 -1

No files matched your search

+8 -1
View File
@@ -292,7 +292,14 @@ function eachFilename(argv, patterns, callback) {
}
try {
const filePaths = globby.sync(patterns, { dot: true });
const filePaths = globby
.sync(patterns, { dot: true })
.map(
filePath =>
path.isAbsolute(filePath)
? path.relative(process.cwd(), filePath)
: filePath
);
if (filePaths.length === 0) {
console.error(`No matching files. Patterns tried: ${patterns.join(" ")}`);
process.exitCode = 2;
@@ -0,0 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`support absolute filename 1`] = `
"regular-module.js
"
`;
@@ -0,0 +1,16 @@
"use strict";
const path = require("path");
const runPrettier = require("../runPrettier");
test("support absolute filename", () => {
const result = runPrettier("cli/ignore-absolute-path", [
path.resolve(__dirname, "../cli/ignore-absolute-path/ignored/module.js"),
path.resolve(__dirname, "../cli/ignore-absolute-path/depth1/ignored/*.js"),
path.resolve(__dirname, "../cli/ignore-absolute-path/regular-module.js"),
"-l"
]);
expect(result.stdout).toMatchSnapshot();
expect(result.status).toEqual(1);
});
@@ -0,0 +1,2 @@
/ignored/
depth1/ignored/
@@ -0,0 +1 @@
'use strict';
@@ -0,0 +1 @@
'use strict';
@@ -0,0 +1 @@
'use strict';