forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprettier.js
More file actions
38 lines (33 loc) · 1003 Bytes
/
prettier.js
File metadata and controls
38 lines (33 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const path = require("path");
const spawn = require("child_process").spawn;
const isWindows = /^win/.test(process.platform);
const prettierCmd = path.resolve(
__dirname,
`../node_modules/.bin/${isWindows ? "prettier.cmd" : "prettier"}`
);
const args = [
"--trailing-comma=none",
"--bracket-spacing=true",
"--write",
"*.js",
"*.json",
"src/*.js",
"src/*/*.js",
"src/components/**/*.css",
"src/test/mochitest/*.js",
"src/test/mochitest/!(examples)/**/*.js"
];
const prettierArgs = process.argv.slice(2).concat(args);
const prettierProc = spawn(prettierCmd, prettierArgs);
prettierProc.stdout.on("data", data => console.log(`${data}`));
prettierProc.stderr.on("data", data => console.log(`stderr: ${data}`));
prettierProc.on("close", code =>
console.log(`prettier ${code === 0 ? "succeeded" : "failed"}`)
);
prettierProc.on("error", error => {
if (error.code == "ENOENT") {
console.log(`Hmm, could not find the path ${cmd}.`);
return;
}
console.log(error);
});