-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathpatch-ai.js
51 lines (43 loc) · 1.05 KB
/
patch-ai.js
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
45
46
47
48
49
50
51
const fs = require("fs");
const path = require("path");
const packageJsonPath = path.join(
// eslint-disable-next-line no-undef
__dirname,
"node_modules",
"ai",
"package.json"
);
fs.readFile(packageJsonPath, "utf8", (err, data) => {
if (err) {
console.error("Error reading package.json:", err);
return;
}
let packageJson;
try {
packageJson = JSON.parse(data);
} catch (err) {
console.error("Error parsing package.json:", err);
return;
}
if (!packageJson.exports) {
console.error("No exports field found in package.json");
return;
}
if (!packageJson.exports["./rsc"]) {
console.error("No ./rsc specifier found in exports field");
return;
}
packageJson.exports["./rsc"].require = packageJson.exports["./rsc"].import;
fs.writeFile(
packageJsonPath,
JSON.stringify(packageJson, null, 2),
"utf8",
(err) => {
if (err) {
console.error("Error writing package.json:", err);
return;
}
console.log("package.json has been patched successfully");
}
);
});