Files
test-repo/tests_integration/__tests__/debug-check.js
T
Joseph Frazier 552ceb30e8 Allow --debug-check to work with stdin (#2013)
* Allow --debug-check to work with stdin

This makes it easier to quickly test formatting code snippets with e.g.

    pbpaste | prettier --debug-check

Before, the following would happen:

    $ pbpaste | prettier --debug-check
    stdin: TypeError: Invalid data, chunk must be a string or buffer, not undefined
        at WriteStream.Socket.write (net.js:693:11)
        at writeOutput (/Users/josephfrazier/workspace/prettier/bin/prettier.js:375:18)
        at getStdin.then.input (/Users/josephfrazier/workspace/prettier/bin/prettier.js:275:7)
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:169:7)
    $

Now, it looks like this:

    $ pbpaste | prettier --debug-check
    (stdin)
    $

* Test that --debug-check still prints filenames

See https://github.com/prettier/prettier/pull/2013#discussion_r120499306
2017-06-06 16:10:24 -07:00

23 lines
540 B
JavaScript

"use strict";
const runPrettier = require("../runPrettier");
test("doesn't crash when --debug-check is passed", () => {
const result = runPrettier("cli/with-shebang", [
"issue1890.js",
"--debug-check"
]);
expect(result.stdout).toEqual("issue1890.js\n");
expect(result.stderr).toEqual("");
});
test("checks stdin with --debug-check", () => {
const result = runPrettier("cli/with-shebang", ["--debug-check"], {
input: "0"
});
expect(result.stdout).toEqual("(stdin)\n");
expect(result.stderr).toEqual("");
});