Updates for tsconfig generation (#12420)

* improve makefile to not remove tsconfigs already in git

* update tsconfig generation script to include packages in eslint and codemods folders

* use git clean
This commit is contained in:
Bogdan Savluk 2020-12-09 16:27:55 +01:00 committed by GitHub
parent a17e4715c9
commit 5067edfdd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 18 deletions

View File

@ -140,9 +140,10 @@ clean: test-clean
clean-tsconfig:
rm -f tsconfig.json
rm -f packages/*/tsconfig.{tsbuildinfo,json}
rm -f codemods/*/tsconfig.{tsbuildinfo,json}
rm -f eslint/*/tsconfig.{tsbuildinfo,json}
git clean packages/*/tsconfig.json -xfq
git clean codemods/*/tsconfig.json -xfq
git clean eslint/*/tsconfig.json -xfq
rm -f */*/tsconfig.tsbuildinfo
test-clean:
$(foreach source, $(SOURCES), \

View File

@ -5,21 +5,29 @@ const fs = require("fs");
const root = path.resolve(__dirname, "../../");
const tsPkgs = fs
.readdirSync(path.join(root, "packages"))
.filter(name => name.startsWith("babel-"))
.map(name => ({
name: name.replace(/^babel-/, "@babel/"),
dir: path.resolve(root, "packages", name),
}))
.filter(({ dir }) => {
try {
fs.statSync(path.join(dir, "src", "index.ts"));
return true;
} catch {
return false;
}
});
function getTsPkgs(subRoot) {
return fs
.readdirSync(path.join(root, subRoot))
.filter(name => name.startsWith("babel-"))
.map(name => ({
name: name.replace(/^babel-/, "@babel/"),
dir: path.resolve(root, subRoot, name),
}))
.filter(({ dir }) => {
try {
fs.statSync(path.join(dir, "src", "index.ts"));
return true;
} catch {
return false;
}
});
}
const tsPkgs = [
...getTsPkgs("packages"),
...getTsPkgs("eslint"),
...getTsPkgs("codemods"),
];
for (const { dir } of tsPkgs) {
const pkg = require(`${dir}/package.json`);