claude-baton 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +23 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { readFileSync, writeFileSync,
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync, statSync, lstatSync, readdirSync, unlinkSync, symlinkSync, rmSync, } from "fs";
|
|
3
3
|
import { execSync } from "child_process";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
5
|
import path from "path";
|
|
@@ -214,15 +214,31 @@ export function installCommands() {
|
|
|
214
214
|
const files = readdirSync(sourceDir).filter((f) => f.endsWith(".md"));
|
|
215
215
|
for (const file of files) {
|
|
216
216
|
const targetPath = path.join(targetDir, file);
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
const sourcePath = path.join(sourceDir, file);
|
|
218
|
+
const name = file.replace(".md", "");
|
|
219
|
+
let isSymlink = false;
|
|
220
|
+
try {
|
|
221
|
+
isSymlink = lstatSync(targetPath).isSymbolicLink();
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// File doesn't exist
|
|
225
|
+
}
|
|
226
|
+
if (isSymlink) {
|
|
227
|
+
// Our symlink — update to point to current package version
|
|
228
|
+
unlinkSync(targetPath);
|
|
229
|
+
symlinkSync(sourcePath, targetPath);
|
|
230
|
+
console.error(` Updated /${name}`);
|
|
231
|
+
installed++;
|
|
232
|
+
}
|
|
233
|
+
else if (existsSync(targetPath)) {
|
|
234
|
+
// Regular file from old install — don't overwrite
|
|
235
|
+
console.error(` Skipping ${name} -- already exists (run uninstall first to upgrade)`);
|
|
220
236
|
skipped++;
|
|
221
237
|
}
|
|
222
238
|
else {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
console.error(`
|
|
239
|
+
// Fresh install — create symlink
|
|
240
|
+
symlinkSync(sourcePath, targetPath);
|
|
241
|
+
console.error(` Linked /${name}`);
|
|
226
242
|
installed++;
|
|
227
243
|
}
|
|
228
244
|
}
|