fix: compute standalone file target path once, use everywhere

Move isStandaloneFile detection and .md suffix normalization before
the existence/force/symlink checks so all code paths use the same
effective target path. Fixes --force not detecting previously installed
standalone skills and symlinks pointing to the wrong filename.
This commit is contained in:
Rohit Ghumare
2026-04-10 21:51:30 +01:00
parent 430bcefaa6
commit ba09309d5b
+6 -8
View File
@@ -472,7 +472,10 @@ export class InstallCommand extends Command {
mkdirSync(installDir, { recursive: true });
}
const targetPath = join(installDir, skillName);
const isStandaloneFile = statSync(sourcePath).isFile();
const targetPath = isStandaloneFile
? join(installDir, skillName.endsWith(".md") ? skillName : `${skillName}.md`)
: join(installDir, skillName);
if (existsSync(targetPath) && !this.force) {
if (!this.quiet) {
@@ -497,21 +500,16 @@ export class InstallCommand extends Command {
rmSync(targetPath, { recursive: true, force: true });
}
const isStandaloneFile = statSync(sourcePath).isFile();
if (useSymlink && primaryPath) {
symlinkSync(primaryPath, targetPath, isStandaloneFile ? "file" : "dir");
} else {
if (isStandaloneFile) {
const fileDest = targetPath.endsWith(".md") ? targetPath : `${targetPath}.md`;
cpSync(sourcePath, fileDest);
cpSync(sourcePath, targetPath);
} else {
cpSync(sourcePath, targetPath, { recursive: true, dereference: true });
}
if (isSymlinkMode && primaryPath === null) {
primaryPath = isStandaloneFile
? (targetPath.endsWith(".md") ? targetPath : `${targetPath}.md`)
: targetPath;
primaryPath = targetPath;
}
if (!isStandaloneFile) {