Add --debug-check cli option (#627)
This let's you run `pp(x) === pp(pp(x))` across an entire codebase quickly. I think it's small enough that we can merge it in to master while we are nailing down all the issues. You can see the output in #610master
parent
ee593bb645
commit
4df5250f74
|
@ -23,6 +23,7 @@ const argv = minimist(process.argv.slice(2), {
|
|||
"help",
|
||||
"version",
|
||||
"debug-print-doc",
|
||||
"debug-check",
|
||||
// Deprecated in 0.0.10
|
||||
"flow-parser"
|
||||
],
|
||||
|
@ -131,6 +132,17 @@ function format(input) {
|
|||
const doc = prettier.__debug.printToDoc(input, options);
|
||||
return prettier.__debug.formatDoc(doc);
|
||||
}
|
||||
|
||||
if (argv["debug-check"]) {
|
||||
const pp = prettier.format(input, options);
|
||||
const pppp = prettier.format(pp, options);
|
||||
if (pp !== pppp) {
|
||||
const diff = require('diff').createTwoFilesPatch('', '', pp, pppp, '', '', {context: 2});
|
||||
console.error(diff);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
return prettier.format(input, options);
|
||||
}
|
||||
|
||||
|
@ -171,7 +183,7 @@ if (stdin) {
|
|||
} else {
|
||||
eachFilename(filepatterns, filename => {
|
||||
fs.readFile(filename, "utf8", (err, input) => {
|
||||
if (write) {
|
||||
if (write || argv["debug-check"]) {
|
||||
console.log(filename);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
"rollup-plugin-node-builtins": "2.0.0",
|
||||
"rollup-plugin-node-globals": "1.1.0",
|
||||
"rollup-plugin-node-resolve": "2.0.0",
|
||||
"rollup-plugin-real-babili": "1.0.0-alpha3"
|
||||
"rollup-plugin-real-babili": "1.0.0-alpha3",
|
||||
"diff": "3.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
|
|
Loading…
Reference in New Issue