diff --git a/src/cli/file-info.js b/src/cli/file-info.js index 91d8381f1..a84bf7ea0 100644 --- a/src/cli/file-info.js +++ b/src/cli/file-info.js @@ -18,7 +18,9 @@ async function logFileInfoOrDie(context) { resolveConfig: config !== false, }); - printToScreen(await format(stringify(fileInfo), { parser: "json" })); + const result = await format(stringify(fileInfo), { parser: "json" }); + + printToScreen(result.trim()); } export default logFileInfoOrDie; diff --git a/src/cli/print-support-info.js b/src/cli/print-support-info.js index cf4672c29..5dc91d766 100644 --- a/src/cli/print-support-info.js +++ b/src/cli/print-support-info.js @@ -14,7 +14,9 @@ async function printSupportInfo() { ), }; - printToScreen(await format(stringify(supportInfo), { parser: "json" })); + const result = await format(stringify(supportInfo), { parser: "json" }); + + printToScreen(result.trim()); } export default printSupportInfo; diff --git a/tests/integration/__tests__/__snapshots__/file-info.js.snap b/tests/integration/__tests__/__snapshots__/file-info.js.snap index 12a9e3537..998a69e31 100644 --- a/tests/integration/__tests__/__snapshots__/file-info.js.snap +++ b/tests/integration/__tests__/__snapshots__/file-info.js.snap @@ -2,113 +2,74 @@ exports[`extracts file-info for a file in not_node_modules (stderr) 1`] = `""`; -exports[`extracts file-info for a file in not_node_modules (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "babel" } -" -`; +exports[`extracts file-info for a file in not_node_modules (stdout) 1`] = `"{ "ignored": false, "inferredParser": "babel" }"`; exports[`extracts file-info for a file in not_node_modules (write) 1`] = `[]`; exports[`extracts file-info for a js file (stderr) 1`] = `""`; -exports[`extracts file-info for a js file (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "babel" } -" -`; +exports[`extracts file-info for a js file (stdout) 1`] = `"{ "ignored": false, "inferredParser": "babel" }"`; exports[`extracts file-info for a js file (write) 1`] = `[]`; exports[`extracts file-info for a known markdown file with no extension (stderr) 1`] = `""`; -exports[`extracts file-info for a known markdown file with no extension (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "markdown" } -" -`; +exports[`extracts file-info for a known markdown file with no extension (stdout) 1`] = `"{ "ignored": false, "inferredParser": "markdown" }"`; exports[`extracts file-info for a known markdown file with no extension (write) 1`] = `[]`; exports[`extracts file-info for a markdown file (stderr) 1`] = `""`; -exports[`extracts file-info for a markdown file (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "markdown" } -" -`; +exports[`extracts file-info for a markdown file (stdout) 1`] = `"{ "ignored": false, "inferredParser": "markdown" }"`; exports[`extracts file-info for a markdown file (write) 1`] = `[]`; exports[`extracts file-info with ignored=false for a file in node_modules when --with-node-modules provided (stderr) 1`] = `""`; -exports[`extracts file-info with ignored=false for a file in node_modules when --with-node-modules provided (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "babel" } -" -`; +exports[`extracts file-info with ignored=false for a file in node_modules when --with-node-modules provided (stdout) 1`] = `"{ "ignored": false, "inferredParser": "babel" }"`; exports[`extracts file-info with ignored=false for a file in node_modules when --with-node-modules provided (write) 1`] = `[]`; exports[`extracts file-info with ignored=true for a file in .prettierignore (stderr) 1`] = `""`; -exports[`extracts file-info with ignored=true for a file in .prettierignore (stdout) 1`] = ` -"{ "ignored": true, "inferredParser": null } -" -`; +exports[`extracts file-info with ignored=true for a file in .prettierignore (stdout) 1`] = `"{ "ignored": true, "inferredParser": null }"`; exports[`extracts file-info with ignored=true for a file in .prettierignore (write) 1`] = `[]`; exports[`extracts file-info with ignored=true for a file in a hand-picked ignore file (stderr) 1`] = `""`; -exports[`extracts file-info with ignored=true for a file in a hand-picked ignore file (stdout) 1`] = ` -"{ "ignored": true, "inferredParser": null } -" -`; +exports[`extracts file-info with ignored=true for a file in a hand-picked ignore file (stdout) 1`] = `"{ "ignored": true, "inferredParser": null }"`; exports[`extracts file-info with ignored=true for a file in a hand-picked ignore file (write) 1`] = `[]`; exports[`extracts file-info with inferredParser=foo when a plugin is hand-picked (stderr) 1`] = `""`; -exports[`extracts file-info with inferredParser=foo when a plugin is hand-picked (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "foo" } -" -`; +exports[`extracts file-info with inferredParser=foo when a plugin is hand-picked (stdout) 1`] = `"{ "ignored": false, "inferredParser": "foo" }"`; exports[`extracts file-info with inferredParser=foo when a plugin is hand-picked (write) 1`] = `[]`; exports[`extracts file-info with inferredParser=null for file.foo (stderr) 1`] = `""`; -exports[`extracts file-info with inferredParser=null for file.foo (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": null } -" -`; +exports[`extracts file-info with inferredParser=null for file.foo (stdout) 1`] = `"{ "ignored": false, "inferredParser": null }"`; exports[`extracts file-info with inferredParser=null for file.foo (write) 1`] = `[]`; exports[`extracts file-info with with ignored=true for a file in node_modules (stderr) 1`] = `""`; -exports[`extracts file-info with with ignored=true for a file in node_modules (stdout) 1`] = ` -"{ "ignored": true, "inferredParser": null } -" -`; +exports[`extracts file-info with with ignored=true for a file in node_modules (stdout) 1`] = `"{ "ignored": true, "inferredParser": null }"`; exports[`extracts file-info with with ignored=true for a file in node_modules (write) 1`] = `[]`; -exports[`file-info should not try resolve config with --no-config (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "babel" } -" -`; +exports[`file-info should not try resolve config with --no-config (stdout) 1`] = `"{ "ignored": false, "inferredParser": "babel" }"`; exports[`file-info should try resolve config (stderr) 1`] = `""`; -exports[`file-info should try resolve config (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "override-js-parser" } -" -`; +exports[`file-info should try resolve config (stdout) 1`] = `"{ "ignored": false, "inferredParser": "override-js-parser" }"`; exports[`file-info should try resolve config (write) 1`] = `[]`; exports[`non-exists ignore path (stderr) 1`] = `""`; -exports[`non-exists ignore path (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "babel" } -" -`; +exports[`non-exists ignore path (stdout) 1`] = `"{ "ignored": false, "inferredParser": "babel" }"`; exports[`non-exists ignore path (write) 1`] = `[]`; diff --git a/tests/integration/__tests__/__snapshots__/infer-parser.js.snap b/tests/integration/__tests__/__snapshots__/infer-parser.js.snap index 08d876da4..84a12db47 100644 --- a/tests/integration/__tests__/__snapshots__/infer-parser.js.snap +++ b/tests/integration/__tests__/__snapshots__/infer-parser.js.snap @@ -76,10 +76,7 @@ exports[`--write with unknown path and no parser multiple files (write) 1`] = ` exports[`--write with unknown path and no parser specific file (stderr) 1`] = `"[error] No parser could be inferred for file "/infer-parser/FOO"."`; -exports[`Interpreters (stdout) 1`] = ` -"{ "ignored": false, "inferredParser": "babel" } -" -`; +exports[`Interpreters (stdout) 1`] = `"{ "ignored": false, "inferredParser": "babel" }"`; exports[`Known/Unknown (stdout) 1`] = `"known.js"`; diff --git a/tests/integration/__tests__/__snapshots__/support-info.js.snap b/tests/integration/__tests__/__snapshots__/support-info.js.snap index 6531893d2..1055f28c3 100644 --- a/tests/integration/__tests__/__snapshots__/support-info.js.snap +++ b/tests/integration/__tests__/__snapshots__/support-info.js.snap @@ -1153,8 +1153,7 @@ exports[`CLI --support-info (stdout) 1`] = ` "type": "boolean" } ] -} -" +}" `; exports[`CLI --support-info (write) 1`] = `[]`;