Also infer parser when using `--list-different` (#1997)

* Also infer parser when using `--list-different`

* Add integration tests for parser inference
master
Philipp Spieß 2017-06-06 17:24:56 +02:00 committed by Christopher Chedeau
parent df7311a7f3
commit d679f235ed
5 changed files with 43 additions and 1 deletions

View File

@ -299,7 +299,12 @@ if (stdin) {
}
if (argv["list-different"]) {
if (!prettier.check(input, options)) {
if (
!prettier.check(
input,
Object.assign({}, options, { filepath: filename })
)
) {
if (!write) {
console.log(filename);
}

View File

@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`infers postcss parser 1`] = `
"/* JavaScript */
\\"use strict\\";
/* Stylesheet */
* {
outline: none;
}
"
`;
exports[`infers postcss parser with --list-different 1`] = `""`;

View File

@ -0,0 +1,18 @@
"use strict";
const runPrettier = require("../runPrettier");
test("infers postcss parser", () => {
const result = runPrettier("cli/with-parser-inference", ["*"]);
expect(result.stdout).toMatchSnapshot();
});
test("infers postcss parser with --list-different", () => {
const result = runPrettier("cli/with-parser-inference", [
"--list-different",
"*"
]);
expect(result.stdout).toMatchSnapshot();
});

View File

@ -0,0 +1,2 @@
/* JavaScript */
"use strict";

View File

@ -0,0 +1,4 @@
/* Stylesheet */
* {
outline: none;
}