aboutsummaryrefslogtreecommitdiff
path: root/node_modules/cosmiconfig/index.js
blob: 0056019a0e8baf1c1fa28667d3f681e6513442eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';

var path = require('path');
var oshomedir = require('os-homedir');
var minimist = require('minimist');
var assign = require('object-assign');
var createExplorer = require('./lib/createExplorer');

var parsedCliArgs = minimist(process.argv);

module.exports = function (moduleName, options) {
  options = assign({
    packageProp: moduleName,
    rc: '.' + moduleName + 'rc',
    js: moduleName + '.config.js',
    argv: 'config',
    rcStrictJson: false,
    stopDir: oshomedir(),
    cache: true,
  }, options);

  if (options.argv && parsedCliArgs[options.argv]) {
    options.configPath = path.resolve(parsedCliArgs[options.argv]);
  }

  return createExplorer(options);
};