Simplify prettier setup (#418)
Use a global command that checks the whole repo to avoid having to repeat the complex commands in each project, and to prevent some files from escaping the check. NOTE: This removes per-project `npm run format` and `npm run check-format`. Use `rush format` and `rush check-format`.
This commit is contained in:
Родитель
310942c07d
Коммит
d24d5cab91
|
@ -0,0 +1,2 @@
|
|||
import { prettier } from "./helpers.js";
|
||||
prettier("--list-different");
|
|
@ -0,0 +1,2 @@
|
|||
import { prettier } from "./helpers.js";
|
||||
prettier("--write");
|
|
@ -68,3 +68,24 @@ export function run(command, args, options) {
|
|||
|
||||
return proc;
|
||||
}
|
||||
|
||||
export function prettier(...args) {
|
||||
let prettier = resolve(repoRoot, "packages/adl/node_modules/.bin/prettier");
|
||||
if (process.platform == "win32") {
|
||||
prettier += ".cmd";
|
||||
}
|
||||
run(
|
||||
prettier,
|
||||
[
|
||||
...args,
|
||||
"--config",
|
||||
".prettierrc.json",
|
||||
"--ignore-path",
|
||||
".prettierignore",
|
||||
"**/*.{ts,js,json}",
|
||||
],
|
||||
{
|
||||
cwd: repoRoot,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,4 +10,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,7 @@
|
|||
"generate-tmlanguage": "node dist-dev/tmlanguage.js",
|
||||
"generate-third-party-notices": "node scripts/generate-third-party-notices.js",
|
||||
"rollup": "rollup --config --failAfterWarnings 2>&1",
|
||||
"package-vsix": "vsce package --yarn",
|
||||
"check-format": "prettier --list-different --config ../../.prettierrc.json --ignore-path ../../.prettierignore \"**/*.{ts,js,json}\"",
|
||||
"format": "prettier --write --config ../../.prettierrc.json --ignore-path ../../.prettierignore \"**/*.{ts,js,json}\""
|
||||
"package-vsix": "vsce package --yarn"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
"dogfood": "node scripts/dogfood.js",
|
||||
"test": "mocha 'dist/test/**/*.js'",
|
||||
"generate-grammar": "grammarkdown --newLine LF language.grammar",
|
||||
"regen-samples": "node scripts/regen-samples.js",
|
||||
"check-format": "prettier --list-different --config ../../.prettierrc.json --ignore-path ../../.prettierignore \"**/*.{ts,js,json}\" \"../../{eng,common/config}/**/*.{ts,js,json}\"",
|
||||
"format": "prettier --write --config ../../.prettierrc.json --ignore-path ../../.prettierignore \"**/*.{ts,js,json}\" \"../../{eng,common/config}/**/*.{ts,js,json}\""
|
||||
"regen-samples": "node scripts/regen-samples.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
Загрузка…
Ссылка в новой задаче