-
Notifications
You must be signed in to change notification settings - Fork 54
Paths that slush searches generators in #29
Copy link
Copy link
Open
Description
So given the below modification to bin/slush.js: getModulePaths()
function getModulesPaths () {
if (process.env.NODE_ENV === 'test') {
return [path.join(__dirname, '..', 'test')];
}
var paths = [];
if (process.platform === 'win32') {
paths.push(path.join(process.env.APPDATA, 'npm', 'node_modules'));
} else {
paths.push('/usr/lib/node_modules');
}
paths.push(path.join(__dirname, '..', '..'));
paths.push.apply(paths, require.main.paths);
// changed here <---------------------
console.log('Paths:');
console.log(paths);
return paths.map(function(path){
return path.toLowerCase();
}).filter(function(path, index, all){
return all.lastIndexOf(path) === index;
});
}
Outputs the following on my ubuntu 14.10 machine when I run 'slush'
Paths:
[ 'usr/lib/node_modules',
'/usr/local/lib/node_modules',
'/usr/local/lib/node_modules/slush/bin/node_modules',
'/usr/local/lib/node_modules/slush/node_modules',
'/usr/local/lib/node_modules',
'/usr/local/node_modules',
'/usr/node_modules',
'/node_modules' ]
Can someone explain the significance of searching all these folders? At first it was a pain just to figure out what require.main.paths was because it's undocumented in node, but even after learning what it was, I still don't understand why it's in use.
Thanks,
Phil
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels