Created
May 7, 2017 09:45
-
-
Save Rokt33r/2d569c22cf2981578cfb77e12143d440 to your computer and use it in GitHub Desktop.
Link Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const path = require('path') | |
const moduleMap = [ | |
'base' | |
] | |
function link (modulePath) { | |
const sourcePath = path.join(__dirname, '..', modulePath) | |
const targetPath = path.join(__dirname, '../node_modules', modulePath) | |
try { | |
// throw if the link doesn't exist yet. | |
fs.statSync(targetPath) | |
fs.unlinkSync(targetPath) | |
} catch (err) { | |
} | |
// create link | |
fs.symlinkSync(sourcePath, targetPath, 'dir') | |
} | |
moduleMap.forEach(link) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment