Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/genie-commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ async function syncPlugin(installType: InstallationType): Promise<void> {
rmSync(cacheDir, { recursive: true, force: true });
}
copyDirSync(pluginSrc, cacheDir);

// Skills live at <pkg>/skills/ (symlink in plugins/genie/ doesn't survive npm)
const skillsSrc = join(globalPkgDir, 'skills');
if (existsSync(skillsSrc) && !existsSync(join(cacheDir, 'skills'))) {
copyDirSync(skillsSrc, join(cacheDir, 'skills'));
}
Comment on lines +401 to +403

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The custom copyDirSync function used here does not correctly handle symbolic links to files. It copies the symlink itself rather than the file it points to, which can result in broken links in the destination cacheDir.

Since your project requires Node.js >= 18.0.0, I recommend using the built-in fs.cpSync function. It is more robust, correctly handles symbolic links, and makes the !existsSync check redundant as it can create the destination directory.

Here is how you could implement it (you will need to import cpSync from node:fs):

if (existsSync(skillsSrc)) {
  cpSync(skillsSrc, join(cacheDir, 'skills'), { recursive: true });
}

Using cpSync would make this fix more reliable. Consider also replacing the other usage of copyDirSync in this file for consistency and to improve overall code health.

} catch (err) {
error(`Failed to copy plugin: ${err}`);
return;
Expand Down
Loading