1 | 'use strict';
|
2 |
|
3 | const configurationError = require('./configurationError');
|
4 | const globalModules = require('global-modules');
|
5 | const resolveFrom = require('resolve-from');
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = function getModulePath(basedir, lookup) {
|
13 |
|
14 |
|
15 |
|
16 | let path = resolveFrom.silent(basedir, lookup);
|
17 |
|
18 | if (!path) {
|
19 | path = resolveFrom.silent(process.cwd(), lookup);
|
20 | }
|
21 |
|
22 | if (!path) {
|
23 | path = resolveFrom.silent(globalModules, lookup);
|
24 | }
|
25 |
|
26 | if (!path) {
|
27 | throw configurationError(`Could not find "${lookup}". Do you need a \`configBasedir\`?`);
|
28 | }
|
29 |
|
30 | return path;
|
31 | };
|