UNPKG

575 BJavaScriptView Raw
1'use strict';
2const os = require('os');
3const isInstalledGlobally = require('is-installed-globally');
4const pkgDir = require('pkg-dir');
5const cosmiconfig = require('cosmiconfig');
6
7module.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};