Skip to content

Commit

Permalink
feat: show stderr output under failed tasks (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
tracernz authored Mar 19, 2021
1 parent 421caa7 commit fcf70cd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flybywiresim/igniter",
"version": "1.1.3",
"version": "1.1.4",
"types": "dist/index.d.ts",
"description": "An intelligent task runner written in Typescript.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const loadConfigTask = async (context: Context): Promise<Task> => {
// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/naming-convention
const __dirname = path.dirname(__filename);

const relativePath = path.relative(__dirname, context.configPath);
const relativePath = path.relative(__dirname, context.configPath).replace('\\', '/');
return (await import(relativePath)).default;
};

Expand Down
7 changes: 7 additions & 0 deletions src/Library/Tasks/GenericTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Context } from '../Contracts/Context';
export default class GenericTask implements Task {
protected context: Context;

protected errorOutput: string;

public status: TaskStatus = TaskStatus.Queued;

/**
Expand Down Expand Up @@ -50,6 +52,7 @@ export default class GenericTask implements Task {
} catch (error) {
if (this.context.debug) throw error;
this.status = TaskStatus.Failed;
if ('stderr' in error) this.errorOutput = error.stderr;
}
}

Expand Down Expand Up @@ -87,6 +90,10 @@ export default class GenericTask implements Task {
if (s === TaskStatus.Skipped) return ['↪', chalk.gray];
return ['⊙', chalk.magenta]; // Replaced with spinner :)
})(this.status);
if (this.status === TaskStatus.Failed && this.errorOutput !== undefined) {
const error = `${indent} ${this.errorOutput.split(/\r?\n/).join(`\n${indent} `)}`;
return colour(`${indent + symbol} ${this.key}\n${error}`);
}
return colour(`${indent + symbol} ${this.key}`);
}
}

0 comments on commit fcf70cd

Please sign in to comment.