Skip to content

Commit 1ce8719

Browse files
committed
refactor: Allow override forge postprocessing task
1 parent 814ad7c commit 1ce8719

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

packages/installer/profile.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LibraryInfo, MinecraftFolder, MinecraftLocation, Version, Version as VersionJson } from '@xmcl/core'
2-
import { AbortableTask, CancelledError, task } from '@xmcl/task'
2+
import { AbortableTask, CancelledError, Task, task } from '@xmcl/task'
33
import { filterEntries, open, readEntry, walkEntriesGenerator } from '@xmcl/unzip'
44
import { spawn } from 'child_process'
55
import { readFile, writeFile } from 'fs/promises'
@@ -70,9 +70,9 @@ export interface PostProcessOptions extends SpawnJavaOptions {
7070
* Custom handlers to handle the post processor
7171
*/
7272
handler?: (postProcessor: PostProcessor) => Promise<boolean>
73-
7473
onPostProcessFailed?: (proc: PostProcessor, jar: string, classPaths: string, mainClass: string, args: string[], error: unknown) => void
7574
onPostProcessSuccess?: (proc: PostProcessor, jar: string, classPaths: string, mainClass: string, args: string[]) => void
75+
customPostProcessTask?: (processor: PostProcessor[], minecraftFolder: MinecraftFolder, options: PostProcessOptions) => Task<void>
7676
}
7777

7878
export interface InstallProfileOption extends LibraryOptions, InstallSideOption, PostProcessOptions {
@@ -267,7 +267,11 @@ export function installByProfileTask(installProfile: InstallProfile, minecraft:
267267

268268
await this.yield(new InstallLibraryTask(installRequiredLibs, minecraftFolder, options))
269269

270-
await this.yield(new PostProcessingTask(processor, minecraftFolder, options))
270+
if (options.customPostProcessTask) {
271+
await this.yield(options.customPostProcessTask(processor, minecraftFolder, options))
272+
} else {
273+
await this.yield(new PostProcessingTask(processor, minecraftFolder, options))
274+
}
271275

272276
if (side === 'client') {
273277
const versionJson: VersionJson = await readFile(minecraftFolder.getVersionJson(installProfile.version)).then((b) => b.toString()).then(JSON.parse)
@@ -455,13 +459,13 @@ export class PostProcessingTask extends AbortableTask<void> {
455459
}
456460
throw e
457461
}
458-
if (proc.outputs) {
459-
const invalidation = await this.isInvalid(proc.outputs)
460-
if (invalidation) {
461-
const [file, expect, actual] = invalidation
462-
throw new PostProcessValidationFailedError(proc.jar, [options.java ?? 'java', ...cmd], 'Validate the output of process failed!', file, expect, actual)
463-
}
464-
}
462+
// if (proc.outputs) {
463+
// const invalidation = await this.isInvalid(proc.outputs)
464+
// if (invalidation) {
465+
// const [file, expect, actual] = invalidation
466+
// throw new PostProcessValidationFailedError(proc.jar, [options.java ?? 'java', ...cmd], 'Validate the output of process failed!', file, expect, actual)
467+
// }
468+
// }
465469
}
466470

467471
protected async process(): Promise<void> {

0 commit comments

Comments
 (0)