janniks / basetag

⚾️ A better way to import local NodeJS modules
MIT License
37 stars 3 forks source link

Link relative rather than absolute? #24

Closed coolaj86 closed 3 years ago

coolaj86 commented 3 years ago

I have a build and deploy process in which the build happens in a temp directory and then deploys to a different directory to be run.

When this happens there's an error because $ points to /tmp/random-name rather than ../.

coolaj86 commented 3 years ago

Looks like this should do the trick on Mac and Linux:

diff --git a/bin/basetag.js b/bin/basetag.js
index 252a1ab..f112b86 100755
--- a/bin/basetag.js
+++ b/bin/basetag.js
@@ -44,7 +44,7 @@ try {
     throw new Error(`- File already exists: ${baseLink}`);
   }

-  fs.symlinkSync(base, baseLink, 'junction');
+  fs.symlinkSync('..', baseLink, 'junction');

   log(`- Created $ symlink to ${base}\n`);
 } catch (error) {
janniks commented 3 years ago

Very very good idea! Someone else had similar problems — I honestly did not now relative symlinks exist, I'll also test this out tomorrow...

janniks commented 3 years ago

Thanks for the idea and patch! 💡