Skip to content

Commit

Permalink
chore: better error log
Browse files Browse the repository at this point in the history
  • Loading branch information
EscapeB committed Oct 11, 2023
1 parent d1ea6f3 commit 89c1fd1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion rush-plugins/rush-git-lfs-plugin/command-line.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "git-lfs-check",
"commandKind": "global",
"summary": "Check Git LFS file in rush project",
"shellCommand": "node <packageFolder>/lib/bin.js",
"shellCommand": "node <packageFolder>/lib/check.js",
"safeForSimultaneousRushProcesses": true
},
{
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion rush-plugins/rush-git-lfs-plugin/src/executor/pull.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Expand All @@ -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}`);
};

Expand Down
10 changes: 4 additions & 6 deletions rush-plugins/rush-git-lfs-plugin/src/executor/run-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -36,15 +34,15 @@ const normalizeCheckContext = (
fix,
files,
option,
spinner,
spinner
};
};

export const runCheck = async (commandLineOption: ICommandLineOptions): Promise<void> => {
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);
}
Expand Down

0 comments on commit 89c1fd1

Please sign in to comment.