Fix create entrypoints script

This commit is contained in:
Nuno Campos
2024-08-01 09:43:30 -07:00
parent eb762c4a77
commit e4905f438a
2 changed files with 11 additions and 5 deletions
+2
View File
@@ -1,4 +1,5 @@
/docs
## GENERATED create-entrypoints.js
/client.cjs
/client.js
/client.d.ts
@@ -7,3 +8,4 @@
/index.js
/index.d.ts
/index.d.cts
## END GENERATED create-entrypoints.js
+9 -5
View File
@@ -97,11 +97,15 @@ const updateConfig = () => {
const endMarker = "## END GENERATED create-entrypoints.js";
const startIdx = lines.findIndex((line) => line.includes(startMarker));
const endIdx = lines.findIndex((line) => line.includes(endMarker));
const newLines = [
...lines.slice(0, startIdx + 1),
...filenames.map((fname) => `/${fname}`),
...lines.slice(endIdx),
];
const newLines = lines.slice(0, startIdx + 1);
if (startIdx === -1) {
newLines.push(startMarker);
}
newLines.push(...filenames.map((fname) => `/${fname}`));
if (endIdx === -1) {
newLines.push(endMarker);
}
newLines.push(...lines.slice(endIdx));
fs.writeFileSync("./.gitignore", newLines.join("\n"));
};