@@ -500,25 +500,24 @@ export function resolveProcessors(side: "client" | "server", installProfile: Ins
500
500
}
501
501
502
502
/**
503
- * Install by install profile. The install profile usually contains some preprocess should run before installing dependencies .
503
+ * Post process the post processors from `InstallProfile` .
504
504
*
505
- * @param installProfile The install profile
505
+ * @param processors The processor info
506
506
* @param minecraft The minecraft location
507
- * @param options The options to install
507
+ * @param java The java executable path
508
508
*/
509
- export function installByProfile ( installProfile : InstallProfile , minecraft : MinecraftLocation , options : InstallProfileOption = { } ) {
510
- return installByProfileTask ( installProfile , minecraft , options ) . execute ( ) . wait ( ) ;
509
+ export function postProcess ( processors : InstallProfile [ "processors" ] , minecraft : MinecraftFolder , java : string ) {
510
+ return postProcessTask ( processors , minecraft , java ) . execute ( ) . wait ( ) ;
511
511
}
512
512
513
513
/**
514
- * Install by install profile. The install profile usually contains some preprocess should run before installing dependencies .
514
+ * Post process the post processors from `InstallProfile` .
515
515
*
516
- * @param installProfile The install profile
516
+ * @param processors The processor info
517
517
* @param minecraft The minecraft location
518
- * @param options The options to install
518
+ * @param java The java executable path
519
519
*/
520
- export function installByProfileTask ( installProfile : InstallProfile , minecraft : MinecraftLocation , options : InstallProfileOption = { } ) {
521
- normailzeDownloader ( options ) ;
520
+ export function postProcessTask ( processors : InstallProfile [ "processors" ] , minecraft : MinecraftFolder , java : string ) {
522
521
async function findMainClass ( lib : string ) {
523
522
const zip = await open ( lib , { lazyEntries : true } ) ;
524
523
const [ manifest ] = await zip . filterEntries ( [ "META-INF/MANIFEST.MF" ] ) ;
@@ -569,29 +568,48 @@ export function installByProfileTask(installProfile: InstallProfile, minecraft:
569
568
throw new Error ( "Fail to process post processing since its validation failed." ) ;
570
569
}
571
570
}
572
- function postProcessingTask ( minecraft : MinecraftFolder , processors : InstallProfile [ "processors" ] , java : string , failImmediately : boolean ) {
573
- return task ( "postProcessing" , async function postProcessing ( ctx ) {
574
- if ( ! processors || processors . length === 0 ) {
575
- return ;
576
- }
571
+ return task ( "postProcessing" , async function postProcessing ( ctx ) {
572
+ if ( ! processors || processors . length === 0 ) {
573
+ return ;
574
+ }
577
575
578
- ctx . update ( 0 , processors . length ) ;
579
- let done = 0 ;
580
- for ( let proc of processors ) {
581
- try {
582
- await postProcess ( minecraft , proc , java ) ;
583
- } catch ( e ) {
584
- e = e || new Error ( `Fail to post porcess ${ proc . jar } : ${ proc . args . join ( " " ) } , ${ proc . classpath . join ( " " ) } ` ) ;
585
- throw e ;
586
- }
587
- ctx . update ( done += 1 , processors . length ) ;
576
+ ctx . update ( 0 , processors . length ) ;
577
+ let done = 0 ;
578
+ for ( let proc of processors ) {
579
+ try {
580
+ await postProcess ( minecraft , proc , java ) ;
581
+ } catch ( e ) {
582
+ e = e || new Error ( `Fail to post porcess ${ proc . jar } : ${ proc . args . join ( " " ) } , ${ proc . classpath . join ( " " ) } ` ) ;
583
+ throw e ;
588
584
}
585
+ ctx . update ( done += 1 , processors . length ) ;
586
+ }
589
587
590
- done += 1 ;
591
- ctx . update ( done , processors . length ) ;
592
- } ) ;
593
- }
588
+ done += 1 ;
589
+ ctx . update ( done , processors . length ) ;
590
+ } ) ;
591
+ }
594
592
593
+ /**
594
+ * Install by install profile. The install profile usually contains some preprocess should run before installing dependencies.
595
+ *
596
+ * @param installProfile The install profile
597
+ * @param minecraft The minecraft location
598
+ * @param options The options to install
599
+ */
600
+ export function installByProfile ( installProfile : InstallProfile , minecraft : MinecraftLocation , options : InstallProfileOption = { } ) {
601
+ return installByProfileTask ( installProfile , minecraft , options ) . execute ( ) . wait ( ) ;
602
+ }
603
+
604
+ /**
605
+ * Install by install profile. The install profile usually contains some preprocess should run before installing dependencies.
606
+ *
607
+ * @param installProfile The install profile
608
+ * @param minecraft The minecraft location
609
+ * @param options The options to install
610
+ */
611
+ export function installByProfileTask ( installProfile : InstallProfile , minecraft : MinecraftLocation , options : InstallProfileOption = { } ) {
612
+ normailzeDownloader ( options ) ;
595
613
return task ( "install" , async function install ( context : Task . Context ) {
596
614
const minecraftFolder = MinecraftFolder . from ( minecraft ) ;
597
615
const java = options . java || "java" ;
@@ -602,7 +620,7 @@ export function installByProfileTask(installProfile: InstallProfile, minecraft:
602
620
let libraries = VersionJson . resolveLibraries ( [ ...installProfile . libraries , ...versionJson . libraries ] ) ;
603
621
604
622
await context . execute ( installResolvedLibrariesTask ( libraries , minecraft , options ) , 50 ) ;
605
- await context . execute ( postProcessingTask ( minecraftFolder , processor , java , options . throwErrorImmediately || false ) , 50 ) ;
623
+ await context . execute ( postProcessTask ( processor , minecraftFolder , java ) , 50 ) ;
606
624
} ) ;
607
625
}
608
626
0 commit comments