Skip to content

Instantly share code, notes, and snippets.

@Rokt33r
Created May 7, 2017 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rokt33r/2d569c22cf2981578cfb77e12143d440 to your computer and use it in GitHub Desktop.
Save Rokt33r/2d569c22cf2981578cfb77e12143d440 to your computer and use it in GitHub Desktop.
Link Directory
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