forked from electrode-io/electrode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload-xarc-options.ts
37 lines (32 loc) · 965 Bytes
/
load-xarc-options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* eslint-disable @typescript-eslint/no-var-requires */
const ck = require("chalker");
const Path = require("path");
const Fs = require("fs");
let loaded;
export function loadXarcOptions(dir: string = process.cwd()) {
if (loaded) {
return loaded;
}
dir = dir || process.cwd();
const filename = Path.join(dir, ".etmp/xarc-options.json");
try {
const data = Fs.readFileSync(filename, "utf-8");
return (loaded = JSON.parse(data));
} catch (err) {
// eslint-disable-next-line
console.error(ck`
<red>ERROR</>: Electrode xarc fail to load <cyan>.etmp/xarc-options.json</> in
dev mode. This means you are trying to use something not through
xarc's development tasks.
full path: ${filename}
Please run "clap setup-dev" once to initialize the file
<cyan>.etmp/xarc-options.json</> before doing your thing that loads
xarc's development code.
`);
return (loaded = {
webpack: {},
babel: {},
options: {}
});
}
}