UNPKG

449 BJavaScriptView Raw
1const fs = require('fs');
2const findDominantFile = require('find-dominant-file');
3const error = require('../error');
4
5const 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
16module.exports = getSavedOptions;