-
Notifications
You must be signed in to change notification settings - Fork 0
/
plopfile.ts
36 lines (30 loc) · 876 Bytes
/
plopfile.ts
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
import type { NodePlopAPI } from "@crutchcorn/plop";
import fs from 'node:fs';
import path from 'node:path';
const projectRoot = ".";
function generators() {
const pkgJsonText = fs.readFileSync(
path.join(projectRoot, "package.json"),
"utf8"
);
const pkgjson = JSON.parse(pkgJsonText);
const workspaces: string[] = pkgjson.workspaces.map((w: string) =>
w.replace("/*", "")
);
// check if each workspace has a generator/config.ts file
const gs = [projectRoot, ...workspaces]
.filter((w: string) => {
const p = path.join(w, "generators/config.ts");
return fs.existsSync(p);
})
.map(
(w: string) =>
projectRoot +
"/" +
path.relative(projectRoot, path.join(w, "generators/config.ts"))
);
return gs;
}
export default async function (plop: NodePlopAPI) {
await plop.load(generators());
}