From fcf70cd6cbe54ebb8cb799fd9e34b637a9d4e638 Mon Sep 17 00:00:00 2001 From: Michael Corcoran Date: Sat, 20 Mar 2021 02:30:08 +1300 Subject: [PATCH] feat: show stderr output under failed tasks (#2) --- package-lock.json | 4 ++-- package.json | 2 +- src/Helpers.ts | 2 +- src/Library/Tasks/GenericTask.ts | 7 +++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1c551f2..1329236 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@flybywiresim/igniter", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@flybywiresim/igniter", - "version": "1.1.2", + "version": "1.1.3", "bin": { "igniter": "dist/binary.mjs" }, diff --git a/package.json b/package.json index 6dcb696..cb79211 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/Helpers.ts b/src/Helpers.ts index cbe3d7e..987a4c4 100644 --- a/src/Helpers.ts +++ b/src/Helpers.ts @@ -21,7 +21,7 @@ export const loadConfigTask = async (context: Context): Promise => { // 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; }; diff --git a/src/Library/Tasks/GenericTask.ts b/src/Library/Tasks/GenericTask.ts index cd220da..b505577 100644 --- a/src/Library/Tasks/GenericTask.ts +++ b/src/Library/Tasks/GenericTask.ts @@ -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; /** @@ -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; } } @@ -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}`); } }