aboutsummaryrefslogtreecommitdiff
path: root/node_modules/liftoff/lib/parse_options.js
blob: ab416b520eaab35bb9d9ce04e410be1bc31a8f2f (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
28
29
30
31
32
33
34
35
const extend = require('extend');

module.exports = function (opts) {
  var defaults = {
    extensions: {
      '.js': null,
      '.json': null
    },
    searchPaths: []
  };
  if (!opts) {
    opts = {};
  }
  if (opts.name) {
    if (!opts.processTitle) {
      opts.processTitle = opts.name;
    }
    if (!opts.configName) {
      opts.configName = opts.name + 'file';
    }
    if (!opts.moduleName) {
      opts.moduleName = opts.name;
    }
  }
  if (!opts.processTitle) {
    throw new Error('You must specify a processTitle.');
  }
  if (!opts.configName) {
    throw new Error('You must specify a configName.');
  }
  if (!opts.moduleName) {
    throw new Error('You must specify a moduleName.');
  }
  return extend(defaults, opts);
};