1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | var nps = require('path');
|
9 | var fs = require('../../lib/lib/utils/fs');
|
10 | var find = require('../../lib/lib/utils/find-parent-dir');
|
11 | var console = require('../../lib/lib/utils/console').default;
|
12 |
|
13 | module.exports = function (path) {
|
14 | var configPath, cwd = process.cwd()
|
15 | if (path) {
|
16 | configPath = nps.resolve(path)
|
17 | if(!fs.isFile(configPath)) {
|
18 | throw new Error('Not found `' + path + '`')
|
19 | } else {
|
20 | cwd = nps.dirname(configPath)
|
21 | }
|
22 | } else {
|
23 | cwd = find('picidae.config.js')
|
24 | if (!cwd) {
|
25 | throw new Error('Not found `picidae.config.js`')
|
26 | }
|
27 | configPath = nps.join(cwd, 'picidae.config.js')
|
28 | }
|
29 |
|
30 | console.log('config in:', configPath)
|
31 | console.log('cwd is:', cwd)
|
32 |
|
33 | return {
|
34 | configPath: configPath,
|
35 | cwd: cwd
|
36 | }
|
37 | }
|