Skip to content

Commit edfd95d

Browse files
committed
fix(ci,core,nx-plugin,create-cli): prevent duplicate process logs
1 parent 1407b37 commit edfd95d

22 files changed

+11
-227
lines changed

packages/ci/src/lib/cli/commands/collect.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { executeProcess } from '@code-pushup/utils';
33
import type { CommandContext } from '../context.js';
44

55
export async function runCollect(
6-
{ bin, config, directory, observer }: CommandContext,
6+
{ bin, config, directory }: CommandContext,
77
{ hasFormats }: { hasFormats: boolean },
88
): Promise<void> {
99
await executeProcess({
@@ -15,6 +15,5 @@ export async function runCollect(
1515
: DEFAULT_PERSIST_FORMAT.map(format => `--persist.format=${format}`)),
1616
],
1717
cwd: directory,
18-
observer,
1918
});
2019
}

packages/ci/src/lib/cli/commands/compare.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { executeProcess } from '@code-pushup/utils';
33
import type { CommandContext } from '../context.js';
44

55
export async function runCompare(
6-
{ bin, config, directory, observer }: CommandContext,
6+
{ bin, config, directory }: CommandContext,
77
{ hasFormats }: { hasFormats: boolean },
88
): Promise<void> {
99
await executeProcess({
@@ -16,6 +16,5 @@ export async function runCompare(
1616
: DEFAULT_PERSIST_FORMAT.map(format => `--persist.format=${format}`)),
1717
],
1818
cwd: directory,
19-
observer,
2019
});
2120
}

packages/ci/src/lib/cli/commands/merge-diffs.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { CommandContext } from '../context.js';
88

99
export async function runMergeDiffs(
1010
files: string[],
11-
{ bin, config, directory, observer }: CommandContext,
11+
{ bin, config, directory }: CommandContext,
1212
): Promise<string> {
1313
const outputDir = path.join(directory, DEFAULT_PERSIST_OUTPUT_DIR);
1414
const filename = `merged-${DEFAULT_PERSIST_FILENAME}`;
@@ -23,7 +23,6 @@ export async function runMergeDiffs(
2323
`--persist.filename=${filename}`,
2424
],
2525
cwd: directory,
26-
observer,
2726
});
2827

2928
return path.join(outputDir, `${filename}-diff.md`);

packages/ci/src/lib/cli/commands/print-config.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export async function runPrintConfig({
1212
config,
1313
directory,
1414
project,
15-
observer,
1615
}: CommandContext): Promise<unknown> {
1716
// unique file name per project so command can be run in parallel
1817
const outputFile = ['code-pushup', 'config', project, 'json']
@@ -33,7 +32,6 @@ export async function runPrintConfig({
3332
`--output=${outputPath}`,
3433
],
3534
cwd: directory,
36-
observer,
3735
});
3836

3937
try {

packages/ci/src/lib/cli/context.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
import type { ProcessObserver } from '@code-pushup/utils';
2-
import { createExecutionObserver } from '../create-execution-observer.js';
31
import type { Settings } from '../models.js';
42
import type { ProjectConfig } from '../monorepo/index.js';
53

64
export type CommandContext = Pick<Settings, 'bin' | 'config' | 'directory'> & {
75
project?: string;
8-
observer?: ProcessObserver;
96
};
107

118
export function createCommandContext(
12-
{ config, bin, directory, silent }: Settings,
9+
{ config, bin, directory }: Settings,
1310
project: ProjectConfig | null | undefined,
1411
): CommandContext {
1512
return {
1613
bin: project?.bin ?? bin,
1714
directory: project?.directory ?? directory,
1815
config,
1916
...(project?.name && { project: project.name }),
20-
observer: createExecutionObserver({ silent }),
2117
};
2218
}

packages/ci/src/lib/cli/context.unit.test.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,29 @@ import { expect } from 'vitest';
22
import { type CommandContext, createCommandContext } from './context.js';
33

44
describe('createCommandContext', () => {
5-
const expectedObserver = expect.objectContaining({
6-
onStderr: expect.any(Function),
7-
onStdout: expect.any(Function),
8-
});
9-
105
it('should pick CLI-related settings in standalone mode', () => {
116
expect(
127
createCommandContext(
138
{
149
bin: 'npx --no-install code-pushup',
1510
config: null,
16-
debug: false,
1711
detectNewIssues: true,
1812
directory: '/test',
19-
logger: console,
2013
monorepo: false,
2114
parallel: false,
2215
nxProjectsFilter: '--with-target={task}',
2316
projects: null,
24-
silent: false,
2517
task: 'code-pushup',
2618
skipComment: false,
2719
configPatterns: null,
20+
searchCommits: false,
2821
},
2922
null,
3023
),
3124
).toStrictEqual<CommandContext>({
3225
bin: 'npx --no-install code-pushup',
3326
directory: '/test',
3427
config: null,
35-
observer: expectedObserver,
3628
});
3729
});
3830

@@ -42,18 +34,16 @@ describe('createCommandContext', () => {
4234
{
4335
bin: 'npx --no-install code-pushup',
4436
config: null,
45-
debug: false,
4637
detectNewIssues: true,
4738
directory: '/test',
48-
logger: console,
4939
monorepo: false,
5040
parallel: false,
5141
nxProjectsFilter: '--with-target={task}',
5242
projects: null,
53-
silent: false,
5443
task: 'code-pushup',
5544
skipComment: false,
5645
configPatterns: null,
46+
searchCommits: false,
5747
},
5848
{
5949
name: 'ui',
@@ -66,7 +56,6 @@ describe('createCommandContext', () => {
6656
directory: '/test/ui',
6757
config: null,
6858
project: 'ui',
69-
observer: expectedObserver,
7059
});
7160
});
7261
});

packages/ci/src/lib/create-execution-observer.int.test.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

packages/ci/src/lib/create-execution-observer.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages/ci/src/lib/create-execution-observer.unit.test.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

packages/ci/src/lib/monorepo/handlers/nx.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ export const nxHandler: MonorepoToolHandler = {
1919
command: 'npx',
2020
args: ['nx', 'report'],
2121
cwd: options.cwd,
22-
observer: options.observer,
2322
ignoreExitCode: true,
2423
})
2524
).code === 0
2625
);
2726
},
2827

29-
async listProjects({ cwd, task, nxProjectsFilter, observer }) {
28+
async listProjects({ cwd, task, nxProjectsFilter }) {
3029
const { stdout } = await executeProcess({
3130
command: 'npx',
3231
args: [
@@ -37,7 +36,6 @@ export const nxHandler: MonorepoToolHandler = {
3736
'--json',
3837
],
3938
cwd,
40-
observer,
4139
});
4240
const projects = parseProjects(stdout);
4341
return projects.toSorted().map(project => ({

0 commit comments

Comments
 (0)