mirror of
https://github.com/rohitg00/skillkit.git
synced 2026-11-18 18:04:26 +00:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user