Fix build (#2981)
parent
201105334d
commit
482ec01c8e
|
@ -325,13 +325,13 @@ function formatFiles(argv) {
|
|||
// mtime based caches.
|
||||
if (output === input) {
|
||||
if (!argv["list-different"]) {
|
||||
console.log(chalk.grey("%s %dms"), filename, Date.now() - start);
|
||||
console.log(chalk.grey(filename), `${Date.now() - start}ms`);
|
||||
}
|
||||
} else {
|
||||
if (argv["list-different"]) {
|
||||
console.log(filename);
|
||||
} else {
|
||||
console.log("%s %dms", filename, Date.now() - start);
|
||||
console.log(filename, `${Date.now() - start}ms`);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,15 +1,47 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`no file diffs with --list-different + formatted file 1`] = `Array []`;
|
||||
exports[`no file diffs with --list-different + formatted file (stderr) 1`] = `""`;
|
||||
|
||||
exports[`no file diffs with --list-different + formatted file 2`] = `Array []`;
|
||||
exports[`no file diffs with --list-different + formatted file (stderr) 2`] = `""`;
|
||||
|
||||
exports[`output with --list-different + unformatted differs when piped 1`] = `
|
||||
"unformated.js[2K[1Gunformated.js
|
||||
exports[`no file diffs with --list-different + formatted file (stdout) 1`] = `"formated.js"`;
|
||||
|
||||
exports[`no file diffs with --list-different + formatted file (stdout) 2`] = `""`;
|
||||
|
||||
exports[`no file diffs with --list-different + formatted file (write) 1`] = `Array []`;
|
||||
|
||||
exports[`no file diffs with --list-different + formatted file (write) 2`] = `Array []`;
|
||||
|
||||
exports[`output with --list-different + unformatted differs when piped (stderr) 1`] = `""`;
|
||||
|
||||
exports[`output with --list-different + unformatted differs when piped (stderr) 2`] = `""`;
|
||||
|
||||
exports[`output with --list-different + unformatted differs when piped (stdout) 1`] = `
|
||||
"unformated.jsunformated.js
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`output with --list-different + unformatted differs when piped 2`] = `
|
||||
exports[`output with --list-different + unformatted differs when piped (stdout) 2`] = `
|
||||
"unformated.js
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`output with --list-different + unformatted differs when piped (write) 1`] = `
|
||||
Array [
|
||||
Object {
|
||||
"content": "var x = 1;
|
||||
",
|
||||
"filename": "unformated.js",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`output with --list-different + unformatted differs when piped (write) 2`] = `
|
||||
Array [
|
||||
Object {
|
||||
"content": "var x = 1;
|
||||
",
|
||||
"filename": "unformated.js",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
exports[`do not write file with --write + formated file (stderr) 1`] = `""`;
|
||||
|
||||
exports[`do not write file with --write + formated file (stdout) 1`] = `
|
||||
"formated.js%s %dms
|
||||
"formated.js
|
||||
"
|
||||
`;
|
||||
|
||||
|
@ -15,14 +15,14 @@ exports[`do not write file with --write + invalid file (stderr) 1`] = `
|
|||
`;
|
||||
|
||||
exports[`do not write file with --write + invalid file (stdout) 1`] = `
|
||||
"invalid.js
|
||||
"
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`write file with --write + unformated file (stderr) 1`] = `""`;
|
||||
|
||||
exports[`write file with --write + unformated file (stdout) 1`] = `
|
||||
"unformated.js%s %dms
|
||||
"unformated.js
|
||||
"
|
||||
`;
|
||||
|
||||
|
|
|
@ -2,47 +2,43 @@
|
|||
|
||||
const runPrettier = require("../runPrettier");
|
||||
|
||||
test("output with --list-different + unformatted differs when piped", () => {
|
||||
describe("output with --list-different + unformatted differs when piped", () => {
|
||||
const result0 = runPrettier(
|
||||
"cli/write",
|
||||
["--write", "--list-different", "--no-color", "unformated.js"],
|
||||
{ stdoutIsTTY: true }
|
||||
);
|
||||
).test({
|
||||
status: 1
|
||||
});
|
||||
|
||||
const result1 = runPrettier(
|
||||
"cli/write",
|
||||
["--write", "--list-different", "--no-color", "unformated.js"],
|
||||
{ stdoutIsTTY: false }
|
||||
);
|
||||
).test({
|
||||
status: 1
|
||||
});
|
||||
|
||||
expect(result0.stdout).toMatchSnapshot();
|
||||
expect(result0.status).toEqual(1);
|
||||
|
||||
expect(result1.stdout).toMatchSnapshot();
|
||||
expect(result1.status).toEqual(1);
|
||||
|
||||
expect(result0.stdout).not.toEqual(result1.stdout);
|
||||
expect(result0.stdout.length).toBeGreaterThan(result1.stdout.length);
|
||||
expect(result0.write).toEqual(result1.write);
|
||||
});
|
||||
|
||||
test("no file diffs with --list-different + formatted file", () => {
|
||||
describe("no file diffs with --list-different + formatted file", () => {
|
||||
const result0 = runPrettier(
|
||||
"cli/write",
|
||||
["--write", "--list-different", "--no-color", "formated.js"],
|
||||
{ stdoutIsTTY: true }
|
||||
);
|
||||
).test({
|
||||
status: 0
|
||||
});
|
||||
|
||||
const result1 = runPrettier(
|
||||
"cli/write",
|
||||
["--write", "--list-different", "--no-color", "formated.js"],
|
||||
{ stdoutIsTTY: false }
|
||||
);
|
||||
|
||||
expect(result0.write).toMatchSnapshot();
|
||||
expect(result0.status).toEqual(0);
|
||||
|
||||
expect(result1.write).toMatchSnapshot();
|
||||
expect(result1.status).toEqual(0);
|
||||
).test({
|
||||
status: 0
|
||||
});
|
||||
|
||||
expect(result0.stdout).not.toEqual(result1.stdout);
|
||||
expect(result0.stdout.length).toBeGreaterThan(result1.stdout.length);
|
||||
|
|
|
@ -107,6 +107,8 @@ function runPrettier(dir, args, options) {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
return { test: testResult };
|
||||
|
|
Loading…
Reference in New Issue