UNPKG

623 BJavaScriptView Raw
1var fs = require('fs');
2var path = require('path');
3
4exports.getStoredPath = function () {
5 var root = process.env.PROJECT_HOME || process.cwd();
6 return path.resolve(root, 'fbp-config.json');
7};
8
9exports.getStored = function () {
10 var storedPath = exports.getStoredPath();
11 if (!fs.existsSync(storedPath)) {
12 throw new Error('Did not find ' + storedPath + '. Run fpb-init first to configure.');
13 }
14 return JSON.parse(fs.readFileSync(storedPath));
15};
16
17exports.saveStored = function (values) {
18 var storedPath = exports.getStoredPath();
19 fs.writeFileSync(storedPath, JSON.stringify(values, null, 2), 'utf-8');
20};