1 | 'use strict';
|
2 | const os = require('os');
|
3 | const isInstalledGlobally = require('is-installed-globally');
|
4 | const pkgDir = require('pkg-dir');
|
5 | const cosmiconfig = require('cosmiconfig');
|
6 |
|
7 | module.exports = async () => {
|
8 | const searchDir = isInstalledGlobally ? os.homedir() : await pkgDir();
|
9 | const searchPlaces = ['.np-config.json', '.np-config.js'];
|
10 | if (!isInstalledGlobally) {
|
11 | searchPlaces.push('package.json');
|
12 | }
|
13 |
|
14 | const explorer = cosmiconfig('np', {
|
15 | searchPlaces,
|
16 | stopDir: searchDir
|
17 | });
|
18 | const {config} = (await explorer.search(searchDir)) || {};
|
19 |
|
20 | return config;
|
21 | };
|