1 |
|
2 |
|
3 | const findUp = require('find-up');
|
4 | const path = require('path');
|
5 |
|
6 |
|
7 | module.exports = function(cwd = process.cwd()) {
|
8 | const creunaRcPath = findUp.sync('.creunarc.json', { cwd });
|
9 | const eslintRcPath = findUp.sync('.eslintrc.json', { cwd });
|
10 |
|
11 | const eslintConfig =
|
12 | eslintRcPath && require(path.relative(__dirname, eslintRcPath));
|
13 |
|
14 | if (!creunaRcPath) {
|
15 | return { componentsPath: cwd, eslintConfig, mockupPath: cwd };
|
16 | }
|
17 |
|
18 | const projectRoot = path.dirname(creunaRcPath);
|
19 | const {
|
20 | componentsPath,
|
21 | mockupPath,
|
22 | dataFileExtension,
|
23 | dataFileContent
|
24 | } = require(path.relative(__dirname, creunaRcPath));
|
25 |
|
26 | return {
|
27 | componentsPath: path.join(projectRoot, componentsPath),
|
28 | mockupPath: path.join(projectRoot, mockupPath),
|
29 | dataFileContent,
|
30 | dataFileExtension,
|
31 | eslintConfig
|
32 | };
|
33 | };
|