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:
Nick Guerrera 2021-04-02 15:01:06 -07:00 коммит произвёл GitHub
Родитель 310942c07d
Коммит d24d5cab91
6 изменённых файлов: 28 добавлений и 7 удалений

Просмотреть файл

@ -0,0 +1,2 @@
import { prettier } from "./helpers.js";
prettier("--list-different");

2
eng/scripts/format.js Normal file
Просмотреть файл

@ -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",