Skip to content

Commit

Permalink
fix: fix error logging with DEBUG=true
Browse files Browse the repository at this point in the history
  • Loading branch information
dziraf committed Dec 3, 2023
1 parent 50c5341 commit cf19d9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/commands/create/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ export class CreateCommand extends BaseCommandHandler<CreateCommandInput> {

process.exit(0);
} catch (error) {
logger.error(
// eslint-disable-next-line max-len
`Encountered an error. Cleaning up working directory. Run command with ${chalk.yellow('DEBUG=true')} to see error details.`,
);
if (process.env.DEBUG === 'true') {
logger.error(error);
} else {
logger.error(
// eslint-disable-next-line max-len
`Encountered an error. Cleaning up working directory. Run command with ${chalk.yellow('DEBUG=true')} to see error details.`,
);
}

logger.info(reportIssuesTip);
await this.cleanProjectDirectory();

Expand All @@ -89,7 +94,7 @@ export class CreateCommand extends BaseCommandHandler<CreateCommandInput> {
try {
await fs.rm(path.join(process.cwd(), this.options.projectName), { recursive: true, force: true });
} catch (err) {
if (process.env.DEBUG === 'true') logger.debug(err);
if (process.env.DEBUG === 'true') logger.warn(err);
// Fail silently
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/create/handlers/LibrarySetup.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class LibrarySetupHandler extends BaseCommandHandler<CreateCommandInput>
}
} catch (error) {
// Do nothing, not all plugins/adapters will have an init script
if (process.env.DEBUG === 'true') logger.debug(error);
if (process.env.DEBUG === 'true') logger.warn(error);
}
}

Expand Down

0 comments on commit cf19d9e

Please sign in to comment.