Skip to content

Commit 5e38156

Browse files
committed
refactor: add various logs
1 parent f40292b commit 5e38156

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

packages/core/src/lib/collect-and-persist.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export async function collectAndPersistReports(
2828

2929
const report = await collect(options);
3030
const sortedScoredReport = sortReport(scoreReport(report));
31+
3132
const persistResults = await persistReport(
3233
report,
3334
sortedScoredReport,

packages/core/src/lib/implementation/runner.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import type {
44
RunnerConfig,
55
RunnerFunction,
66
} from '@code-pushup/models';
7-
import { calcDuration, executeProcess, readJsonFile } from '@code-pushup/utils';
7+
import {
8+
calcDuration,
9+
executeProcess,
10+
readJsonFile,
11+
removeDirectoryIfExists,
12+
} from '@code-pushup/utils';
813

914
export type RunnerResult = {
1015
date: string;
@@ -26,7 +31,8 @@ export async function executeRunnerConfig(
2631
});
2732

2833
// read process output from file system and parse it
29-
const outputs = await readJsonFile(path.join(process.cwd(), outputFile));
34+
const outputs = await readJsonFile(outputFile);
35+
await removeDirectoryIfExists(path.dirname(outputFile));
3036

3137
// transform unknownAuditOutputs to auditOutputs
3238
const audits = outputTransform ? await outputTransform(outputs) : outputs;

packages/plugin-eslint/src/lib/runner/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
filePathToCliArg,
1313
objectToCliArgs,
1414
readJsonFile,
15+
ui,
1516
} from '@code-pushup/utils';
1617
import type { ESLintPluginRunnerConfig, ESLintTarget } from '../config.js';
1718
import { lint } from './lint.js';
@@ -25,6 +26,8 @@ export async function executeRunner({
2526
const { slugs, targets } =
2627
await readJsonFile<ESLintPluginRunnerConfig>(runnerConfigPath);
2728

29+
ui().logger.log(`ESLint plugin executing ${targets.length} lint targets`);
30+
2831
const linterOutputs = await targets.reduce(
2932
async (acc, target) => [...(await acc), await lint(target)],
3033
Promise.resolve<LinterOutput[]>([]),

packages/utils/src/lib/execute-process.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { gray } from 'ansis';
12
import {
23
type ChildProcess,
34
type ChildProcessByStdio,
@@ -6,6 +7,7 @@ import {
67
spawn,
78
} from 'node:child_process';
89
import type { Readable, Writable } from 'node:stream';
10+
import { ui } from './logging.js';
911
import { calcDuration } from './reports/utils.js';
1012

1113
/**
@@ -148,6 +150,9 @@ export function executeProcess(cfg: ProcessConfig): Promise<ProcessResult> {
148150
const date = new Date().toISOString();
149151
const start = performance.now();
150152

153+
const logCommand = [command, ...(args || [])].join(' ');
154+
ui().logger.log(gray(`Executing command:\n${logCommand}`));
155+
151156
return new Promise((resolve, reject) => {
152157
// shell:true tells Windows to use shell command for spawning a child process
153158
const spawnedProcess = spawn(command, args ?? [], {

0 commit comments

Comments
 (0)