Blame view

node_modules/bower/lib/util/resolve.js 555 Bytes
2dda2e10   Administrator   generator ignore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  var requireg = require('requireg');
  var resolve = require('resolve');
  
  function startsWith(string, searchString, position) {
      position = position || 0;
      return string.substr(position, searchString.length) === searchString;
  };
  
  module.exports = function (id, options) {
      var resolvedPath;
  
      var cwd = (options || {}).cwd || process.cwd();
  
      try {
          resolvedPath = resolve.sync(id, { basedir: cwd });
      } catch (e) {
          // Fallback to global require
          resolvedPath = requireg.resolve(id);
      }
  
      return resolvedPath;
  }