Created
January 2, 2015 20:35
-
-
Save bromanko/1ed239d48bd51d3c1389 to your computer and use it in GitHub Desktop.
Symlink Dependencies as Virtual Node modules
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
'use strict'; | |
/* | |
* Symlinks filepaths from earnestDependencies in package.json to a | |
* corresponding entry in the root node_modules directory | |
*/ | |
var packageJson = require('../package'); | |
var exec = require('child_process').exec; | |
console.log('*** Symlinking local dependencies into node_modules ***'); | |
exec('mkdir -p node_modules', function (error, stdout, stderr) { | |
if (error) { | |
console.error(stderr); | |
process.exit(1); | |
} | |
console.log(stdout); | |
var depNames = Object.keys(packageJson.earnestDependencies); | |
depNames.forEach(function (depName) { | |
var filePath = '.' + packageJson.earnestDependencies[depName]; | |
exec('ln -svnf ' + filePath + ' ./node_modules/' + depName, function (error, stdout, stderr) { | |
if (error) { | |
console.error(stderr); | |
process.exit(1); | |
} | |
console.log('Symlinked:', filePath, '-> ./node_modules/' + depName); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment