Skip to content

Commit 83e2bce

Browse files
committed
Pipe dryRun through handle-patch
1 parent 67c3323 commit 83e2bce

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/commands/patch/cmd-patch.mts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ async function run(
8888
return
8989
}
9090

91-
if (dryRun) {
92-
logger.log(constants.DRY_RUN_NOT_SAVING)
93-
return
94-
}
95-
9691
let [cwd = '.'] = cli.input
9792
// Note: path.resolve vs .join:
9893
// If given path is absolute then cwd should not affect it.
@@ -115,6 +110,7 @@ async function run(
115110

116111
await handlePatch({
117112
cwd,
113+
dryRun,
118114
outputKind,
119115
packages,
120116
spinner,

src/commands/patch/handle-patch.mts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ interface PURL {
2121
subpath?: string
2222
}
2323

24-
export interface HandlePatchConfig {
25-
cwd: string
26-
outputKind: OutputKind
27-
packages: string[]
28-
spinner: typeof constants.spinner
29-
}
30-
3124
async function applyNPMPatches(
3225
patches: Array<{ key: string; purl: PURL; patch: PatchRecord }>,
3326
dryRun: boolean,
@@ -280,26 +273,33 @@ async function readPackageJson(
280273
return null
281274
}
282275

276+
export interface HandlePatchConfig {
277+
cwd: string
278+
dryRun: boolean
279+
outputKind: OutputKind
280+
packages: string[]
281+
spinner: typeof constants.spinner
282+
}
283+
283284
export async function handlePatch({
284285
cwd,
286+
dryRun,
285287
outputKind,
286288
packages,
287289
spinner,
288290
}: HandlePatchConfig): Promise<void> {
289-
const dryRun = false // TODO: Add dryRun support via config
290-
291291
try {
292292
const dotSocketDirPath = path.join(cwd, '.socket')
293293
const manifestPath = path.join(dotSocketDirPath, 'manifest.json')
294294

295-
// Read the manifest file
295+
// Read the manifest file.
296296
const manifestContent = await fs.readFile(manifestPath, 'utf-8')
297297
const manifestData = JSON.parse(manifestContent)
298298

299-
// Validate the schema
299+
// Validate the schema.
300300
const validated = PatchManifestSchema.parse(manifestData)
301301

302-
// Parse PURLs and group by ecosystem
302+
// Parse PURLs and group by ecosystem.
303303
const patchesByEcosystem: Record<
304304
string,
305305
Array<{ key: string; purl: PURL; patch: PatchRecord }>

0 commit comments

Comments
 (0)