1 | const fs = require('fs');
|
2 | const findDominantFile = require('find-dominant-file');
|
3 | const error = require('../error');
|
4 |
|
5 | const getSavedOptions = (app, cwd = process.cwd()) => {
|
6 | if (!app.rcFile) return {};
|
7 | const rcFile = findDominantFile(cwd, app.rcFile);
|
8 | if (!rcFile) return {};
|
9 | try {
|
10 | return JSON.parse(fs.readFileSync(rcFile).toString());
|
11 | } catch(e) {
|
12 | throw error(`'${rcFile}' malformed.`);
|
13 | }
|
14 | };
|
15 |
|
16 | module.exports = getSavedOptions;
|