mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
config: add more error handling
This commit is contained in:
parent
4e6fc051ec
commit
2a6ec3e955
1 changed files with 6 additions and 3 deletions
|
|
@ -17,9 +17,12 @@ function watch () {
|
|||
|
||||
function exec (str) {
|
||||
const script = new vm.Script(str);
|
||||
const mod = {};
|
||||
script.runInNewContext(mod);
|
||||
const cfg = mod.exports.config;
|
||||
const module = {};
|
||||
script.runInNewContext({ module });
|
||||
const cfg = module.exports.config;
|
||||
if (!module.exports) {
|
||||
throw new Error('Error reading configuration: `module.exports` not set');
|
||||
}
|
||||
if (!cfg) {
|
||||
throw new Error('Error reading configuration: `config` key is missing');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue