Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths that slush searches generators in #29

Open
olsonpm opened this issue Jan 24, 2015 · 0 comments
Open

Paths that slush searches generators in #29

olsonpm opened this issue Jan 24, 2015 · 0 comments

Comments

@olsonpm
Copy link

olsonpm commented Jan 24, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant