-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pnpmfile.cjs
44 lines (36 loc) · 1017 Bytes
/
.pnpmfile.cjs
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
39
40
41
42
43
44
const fs = require("fs");
const path = require("path");
console.log("Running pnpmfile.cjs script");
function createFile(filePath, content) {
if (!fs.existsSync(filePath)) {
fs.writeFileSync(filePath, content);
console.log(`Created file: ${filePath}`);
}
}
function createDirectory(dirPath) {
if (!fs.existsSync(dirPath)) {
fs.mkdirSync(dirPath, { recursive: true });
console.log(`Created directory: ${dirPath}`);
}
}
function readPackage(pkg) {
try {
const createLibDir = path.join(
__dirname,
"packages/codegen/dist/create-lib",
);
createDirectory(createLibDir);
const cliFilePath = path.join(__dirname, "packages/codegen/dist/cli.js");
createFile(cliFilePath, "#! /usr/bin/env node\n");
const indexFilePath = path.join(createLibDir, "index.js");
createFile(indexFilePath, "#! /usr/bin/env node\n");
} catch (err) {
console.error("Error creating files:", err);
}
return pkg;
}
module.exports = {
hooks: {
readPackage,
},
};