Skip to content

Commit

Permalink
fix: add logger fatal if fails on startup (#2288)
Browse files Browse the repository at this point in the history
fix #2287
  • Loading branch information
juanpicado committed Jun 12, 2021
1 parent 38ca095 commit 558dd3f
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/lib/cli/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ export class InitCommand extends Command {
examples: [
[`Runs the server with the default configuration`, `verdaccio`],
[`Runs the server in the port 5000`, `verdaccio --listen 5000`],
[
`Runs the server by using a different absolute location of the configuration file`,
`verdaccio --config /home/user/verdaccio/config.yaml`,
],
[`Runs the server by using a different absolute location of the configuration file`, `verdaccio --config /home/user/verdaccio/config.yaml`],
],
});

Expand All @@ -50,8 +47,9 @@ export class InitCommand extends Command {
});

async execute() {
let configPathLocation;
try {
const configPathLocation = findConfigFile(this.config as string);
configPathLocation = findConfigFile(this.config as string);
const verdaccioConfiguration = parseConfigFile(configPathLocation);
if (!verdaccioConfiguration.self_path) {
verdaccioConfiguration.self_path = path.resolve(configPathLocation);
Expand All @@ -63,15 +61,9 @@ export class InitCommand extends Command {
logger.logger.warn({ file: configPathLocation }, 'config file - @{file}');
process.title = (verdaccioConfiguration.web && verdaccioConfiguration.web.title) || 'verdaccio';

startVerdaccio(
verdaccioConfiguration,
this.listen as string,
configPathLocation,
pkgVersion,
pkgName,
listenDefaultCallback
);
startVerdaccio(verdaccioConfiguration, this.listen as string, configPathLocation, pkgVersion, pkgName, listenDefaultCallback);
} catch (err) {
logger.logger.fatal({ file: configPathLocation, err: err }, 'cannot open config file @{file}: @{!err.message}');
process.exit(1);
}
}
Expand Down

0 comments on commit 558dd3f

Please sign in to comment.