Skip to content

Commit

Permalink
log errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mmeigs committed Nov 20, 2023
1 parent b97835c commit 97cbc8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/commands/src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface CliCommandParams {
options?: SpawnOptions;
writeStream?: fs.WriteStream;
writeTarget?: Writable;
logger?: (message: string) => void;
}

export interface CliCommandResponse {
Expand Down Expand Up @@ -157,6 +158,7 @@ export async function executeCliCommand({
args = [],
options = {},
writeStream,
logger,
}: CliCommandParams): Promise<CliCommandResponse> {
return new Promise((resolve, reject) => {
const outputText: string[] = [];
Expand All @@ -181,6 +183,11 @@ export async function executeCliCommand({
if (writeStream) writeStream.end();

if (exitCode !== 0) {
if (logger) {
logger(`ERROR! The command ${command} closed with an exit code other than 0: ${exitCode}.`);
logger('Arguments provided: ' + args);
logger('Options provided: ' + options);
}
console.error(`ERROR! The command ${command} closed with an exit code other than 0: ${exitCode}.`);
console.error('Arguments provided: ', args);
console.error('Options provided: ', options);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/src/shared/next-gen-parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function nextGenParse({ job, preppedLogger }: NextGenParseParams):
preppedLogger(`COMMAND for parse: ${commandArgs.join(' ')}`);

try {
await executeCliCommand({ command: 'snooty', args: commandArgs });
await executeCliCommand({ command: 'snooty', args: commandArgs, logger: preppedLogger });
} catch (error) {
preppedLogger(`ERROR: ${error}\n\n`);
}
Expand Down

0 comments on commit 97cbc8b

Please sign in to comment.