From 89c1fd1f98b9e0b60c4f1f77808cf47ee96137bb Mon Sep 17 00:00:00 2001 From: EscapeB Date: Wed, 11 Oct 2023 20:39:50 +0800 Subject: [PATCH] chore: better error log --- .../improve-better_error_log_2023-10-11-12-32.json | 10 ++++++++++ rush-plugins/rush-git-lfs-plugin/command-line.json | 2 +- .../rush-git-lfs-plugin/src/{bin.ts => check.ts} | 0 rush-plugins/rush-git-lfs-plugin/src/executor/pull.ts | 4 +++- .../rush-git-lfs-plugin/src/executor/run-check.ts | 10 ++++------ 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 common/changes/rush-git-lfs-plugin/improve-better_error_log_2023-10-11-12-32.json rename rush-plugins/rush-git-lfs-plugin/src/{bin.ts => check.ts} (100%) diff --git a/common/changes/rush-git-lfs-plugin/improve-better_error_log_2023-10-11-12-32.json b/common/changes/rush-git-lfs-plugin/improve-better_error_log_2023-10-11-12-32.json new file mode 100644 index 0000000..42e2b5d --- /dev/null +++ b/common/changes/rush-git-lfs-plugin/improve-better_error_log_2023-10-11-12-32.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "rush-git-lfs-plugin", + "comment": "Provide better error log in rush git-lfs-pull", + "type": "patch" + } + ], + "packageName": "rush-git-lfs-plugin" +} \ No newline at end of file diff --git a/rush-plugins/rush-git-lfs-plugin/command-line.json b/rush-plugins/rush-git-lfs-plugin/command-line.json index ad372cf..ca6acb9 100644 --- a/rush-plugins/rush-git-lfs-plugin/command-line.json +++ b/rush-plugins/rush-git-lfs-plugin/command-line.json @@ -5,7 +5,7 @@ "name": "git-lfs-check", "commandKind": "global", "summary": "Check Git LFS file in rush project", - "shellCommand": "node /lib/bin.js", + "shellCommand": "node /lib/check.js", "safeForSimultaneousRushProcesses": true }, { diff --git a/rush-plugins/rush-git-lfs-plugin/src/bin.ts b/rush-plugins/rush-git-lfs-plugin/src/check.ts similarity index 100% rename from rush-plugins/rush-git-lfs-plugin/src/bin.ts rename to rush-plugins/rush-git-lfs-plugin/src/check.ts diff --git a/rush-plugins/rush-git-lfs-plugin/src/executor/pull.ts b/rush-plugins/rush-git-lfs-plugin/src/executor/pull.ts index ce48e30..1876a7b 100644 --- a/rush-plugins/rush-git-lfs-plugin/src/executor/pull.ts +++ b/rush-plugins/rush-git-lfs-plugin/src/executor/pull.ts @@ -1,6 +1,6 @@ import { Executable } from '@rushstack/node-core-library'; import { SpawnSyncReturns } from 'child_process'; - +import { terminal, withPrefix } from '../helpers/terminal'; interface IProject { path: string; } @@ -19,6 +19,8 @@ const getPackagesByProjectName = ( if (result.status === 0) { return JSON.parse(result.stdout); } + terminal.writeLine(withPrefix('Logs:\n'), result.stdout); + terminal.writeErrorLine(withPrefix('Errors:\n'), result.stderr); throw new Error(`rush list error code ${result.status}`); }; diff --git a/rush-plugins/rush-git-lfs-plugin/src/executor/run-check.ts b/rush-plugins/rush-git-lfs-plugin/src/executor/run-check.ts index 3e15970..ca3b050 100644 --- a/rush-plugins/rush-git-lfs-plugin/src/executor/run-check.ts +++ b/rush-plugins/rush-git-lfs-plugin/src/executor/run-check.ts @@ -6,12 +6,10 @@ import { getFilePathsFromChangedFiles, validateFilePaths } from '../helpers/file import { terminal, withPrefix } from '../helpers/terminal'; import type { NestedRequired } from '../helpers/type'; -import type { ICommandLineOptions } from '../bin'; +import type { ICommandLineOptions } from '../check'; import ora from 'ora'; -const normalizeCheckContext = ( - commandLineOption: ICommandLineOptions -): IGitLFSCheckModuleContext => { +const normalizeCheckContext = (commandLineOption: ICommandLineOptions): IGitLFSCheckModuleContext => { // eslint-disable-next-line prefer-const let { file: files, fix } = commandLineOption; if (typeof files === 'undefined') { @@ -36,7 +34,7 @@ const normalizeCheckContext = ( fix, files, option, - spinner, + spinner }; }; @@ -44,7 +42,7 @@ export const runCheck = async (commandLineOption: ICommandLineOptions): Promise< const checker: GitLFSCheckModule = new GitLFSCheckModule(); const ctx: IGitLFSCheckModuleContext = normalizeCheckContext(commandLineOption); await checker.run(ctx); - if (ctx.result.filter(e => typeof e.errorType !== 'undefined' && !e.fixed).length > 0) { + if (ctx.result.filter((e) => typeof e.errorType !== 'undefined' && !e.fixed).length > 0) { if (ctx.option.errorTips) { terminal.writeLine(ctx.option.errorTips); }