From 4c921df87c41136e01ee91cf0ec02342adb7898a Mon Sep 17 00:00:00 2001 From: RubenPX Date: Sat, 9 Dec 2023 17:00:25 +0000 Subject: [PATCH] fix if link exists and try to link --- scripts/post-install.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/post-install.js b/scripts/post-install.js index 34b631af..1c953a81 100644 --- a/scripts/post-install.js +++ b/scripts/post-install.js @@ -47,9 +47,16 @@ async function linkSharedResources(pkgJSON, packagePath) { fs.mkdirSync(path.resolve(finalLinkPath, ".."), { recursive: true }) } - fs.symlinkSync(originClassPath, finalLinkPath, "dir") - - console.log(`🔗 Linked resouce [${resource}] to [${finalLinkPath}]`) + try { + fs.symlinkSync(originClassPath, finalLinkPath, "dir") + console.log(`🔗 Linked resouce [${resource}] to [${finalLinkPath}]`) + } catch (error) { + if (error.code && error.code == 'EEXIST') { + fs.unlinkSync(finalLinkPath) + fs.symlinkSync(originClassPath, finalLinkPath, "dir") + console.log(`🔗 Linked resouce [${resource}] to [${finalLinkPath}]`) + } + } continue } @@ -138,4 +145,4 @@ async function main() { console.timeEnd("✅ post-install tooks:") } -main().catch(console.error) \ No newline at end of file +main().catch(console.error)