UNPKG

692 BJavaScriptView Raw
1const fs = require("fs"),
2 path = require("path"),
3 shell = require("shelljs"),
4 yaml = require("js-yaml");
5
6const appPath = path.join(process.cwd(), "app");
7
8module.exports = file => {
9
10 const fullPath = path.join(appPath, file);
11
12 try {
13 require.resolve(fullPath);
14 delete require.cache[fullPath];
15 const contents = fs.readFileSync(fullPath, "utf8");
16 if (process.env.NODE_ENV === "development") shell.echo(`${file} loaded from .app/ directory`);
17 return yaml.safeLoad(contents, {json: true});
18 }
19 catch (e) {
20 if (process.env.NODE_ENV === "development") shell.echo(`${file} does not exist in .app/ directory, using default`);
21 return false;
22 }
23
24};