Skip to content

Commit acccbdc

Browse files
committed
fix(client): throw user-friendly error if config file missing
1 parent 92c6660 commit acccbdc

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/cli/client.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@ const configFilepath = program.args[0] || defaultConfigFilepath;
2323
// Load and validate configuration.
2424
const ajv = new Ajv();
2525
addAjvFormats(ajv);
26-
const config = Object.assign(
27-
{
28-
localApps: [],
29-
remoteUrl: "https://lw.gocho.live",
30-
},
31-
require(path.resolve(configFilepath)),
32-
);
26+
let config;
27+
try {
28+
config = Object.assign(
29+
{
30+
localApps: [],
31+
remoteUrl: "https://lw.gocho.live",
32+
},
33+
require(path.resolve(configFilepath)),
34+
);
35+
} catch (error) {
36+
if (error.code === "MODULE_NOT_FOUND") {
37+
throw new Error(`Configuration file not found: ${configFilepath}`);
38+
}
39+
throw error;
40+
}
3341
const isConfigValid = ajv.validate(
3442
require("../../schemas/config-schema.json"),
3543
config,

0 commit comments

Comments
 (0)