Skip to content

Commit 2beea40

Browse files
committed
Run merge-diffs command in project where code-pushup is installed
1 parent 45fb3ae commit 2beea40

File tree

5 files changed

+44
-20
lines changed

5 files changed

+44
-20
lines changed

dist/index.js

Lines changed: 25 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli/context.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
import type { ActionInputs } from '../inputs'
2+
import type { ProjectConfig } from '../monorepo'
23

34
export type CommandContext = Pick<
45
ActionInputs,
56
'bin' | 'config' | 'directory' | 'silent'
67
> & {
78
project?: string
89
}
10+
11+
export function createCommandContext(
12+
inputs: ActionInputs,
13+
project: ProjectConfig | null | undefined
14+
): CommandContext {
15+
return {
16+
project: project?.name,
17+
bin: project?.bin ?? inputs.bin,
18+
directory: project?.directory ?? inputs.directory,
19+
config: inputs.config,
20+
silent: inputs.silent
21+
}
22+
}

src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export { collect } from './commands/collect'
22
export { compare } from './commands/compare'
33
export { mergeDiffs } from './commands/merge-diffs'
44
export { printConfig } from './commands/print-config'
5-
export type { CommandContext } from './context'
5+
export { createCommandContext, type CommandContext } from './context'
66
export {
77
findPersistedFiles,
88
projectToFilename,

src/main.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import {
1313
import {
1414
collect,
1515
compare,
16+
createCommandContext,
1617
mergeDiffs,
1718
printConfig,
18-
type CommandContext,
1919
type PersistedCliFiles
2020
} from './cli'
2121
import { commentOnPR } from './comment'
@@ -52,7 +52,7 @@ export async function run(
5252
if (diffJsonPaths.length > 0) {
5353
const { mdFilePath, artifactData } = await mergeDiffs(
5454
diffJsonPaths,
55-
inputs
55+
createCommandContext(inputs, projects[0])
5656
)
5757
core.debug(`Merged ${diffJsonPaths.length} diffs into ${mdFilePath}`)
5858
commentMdPath = mdFilePath
@@ -90,13 +90,7 @@ async function runOnProject(
9090
artifact: DefaultArtifactClient,
9191
git: SimpleGit
9292
): Promise<PersistedCliFiles | null> {
93-
const ctx: CommandContext = {
94-
project: project?.name,
95-
bin: project?.bin ?? inputs.bin,
96-
directory: project?.directory ?? inputs.directory,
97-
config: inputs.config,
98-
silent: inputs.silent
99-
}
93+
const ctx = createCommandContext(inputs, project)
10094

10195
const { jsonFilePath: currReportPath, artifactData: reportArtifact } =
10296
await collect(ctx)

0 commit comments

Comments
 (0)