|
1 | 1 | 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' |
3 | 3 | import { filterEntries, open, readEntry, walkEntriesGenerator } from '@xmcl/unzip'
|
4 | 4 | import { spawn } from 'child_process'
|
5 | 5 | import { readFile, writeFile } from 'fs/promises'
|
@@ -70,9 +70,9 @@ export interface PostProcessOptions extends SpawnJavaOptions {
|
70 | 70 | * Custom handlers to handle the post processor
|
71 | 71 | */
|
72 | 72 | handler?: (postProcessor: PostProcessor) => Promise<boolean>
|
73 |
| - |
74 | 73 | onPostProcessFailed?: (proc: PostProcessor, jar: string, classPaths: string, mainClass: string, args: string[], error: unknown) => void
|
75 | 74 | onPostProcessSuccess?: (proc: PostProcessor, jar: string, classPaths: string, mainClass: string, args: string[]) => void
|
| 75 | + customPostProcessTask?: (processor: PostProcessor[], minecraftFolder: MinecraftFolder, options: PostProcessOptions) => Task<void> |
76 | 76 | }
|
77 | 77 |
|
78 | 78 | export interface InstallProfileOption extends LibraryOptions, InstallSideOption, PostProcessOptions {
|
@@ -267,7 +267,11 @@ export function installByProfileTask(installProfile: InstallProfile, minecraft:
|
267 | 267 |
|
268 | 268 | await this.yield(new InstallLibraryTask(installRequiredLibs, minecraftFolder, options))
|
269 | 269 |
|
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 | + } |
271 | 275 |
|
272 | 276 | if (side === 'client') {
|
273 | 277 | 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> {
|
455 | 459 | }
|
456 | 460 | throw e
|
457 | 461 | }
|
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 | + // } |
465 | 469 | }
|
466 | 470 |
|
467 | 471 | protected async process(): Promise<void> {
|
|
0 commit comments