@@ -95,13 +95,16 @@ class Applesign {
9595 }
9696 await this . _pullMobileProvision ( ) ;
9797 this . emit ( "message" , "File: " + this . config . file ) ;
98- this . emit ( "message" , "Outdir : " + this . config . outdir ) ;
98+ this . emit ( "message" , "Tempdir : " + this . config . tempdir ) ;
9999 if ( tools . isDirectory ( this . config . file as string ) ) {
100100 throw new Error ( "This is a directory" ) ;
101101 }
102102 try {
103- await this . unzipIPA ( this . config . file , this . config . outdir ) ;
104- const appDirectory = path . join ( this . config . outdir , "/Payload" ) ;
103+ if ( ! this . config . tempdir ) {
104+ throw new Error ( "No tempdir specified" ) ;
105+ }
106+ await this . unzipIPA ( this . config . file , this . config . tempdir ) ;
107+ const appDirectory = path . join ( this . config . tempdir , "/Payload" ) ;
105108 this . config . appdir = getAppDirectory ( appDirectory ) ;
106109 if ( this . config . debug ) {
107110 this . debugObject = { } ;
@@ -337,7 +340,7 @@ class Applesign {
337340 if ( ! val ) {
338341 return ;
339342 }
340- const f = path . replace ( this . config . outdir + "/" , "" ) ;
343+ const f = path . replace ( this . config . tempdir + "/" , "" ) ;
341344 if ( ! this . debugObject ) {
342345 this . debugObject = { } ;
343346 }
@@ -829,10 +832,9 @@ class Applesign {
829832 if ( this . config . noclean ) {
830833 return ;
831834 }
832- const outdir = this . config . outdir ;
833- this . emit ( "message" , "Cleaning up " + outdir ) ;
834- // await tools.asyncRimraf(this.config.outfile);
835- return tools . asyncRimraf ( outdir ) ;
835+ const tempdir = this . config . tempdir ;
836+ this . emit ( "message" , "Cleaning up " + tempdir ) ;
837+ return tools . asyncRimraf ( tempdir ) ;
836838 }
837839
838840 async cleanupTmp ( ) {
@@ -847,15 +849,18 @@ class Applesign {
847849 return ;
848850 }
849851 const ipaIn = this . config . file as string ;
850- const ipaOut = getOutputPath ( this . config . outdir , this . config . outfile ! ) ;
852+ if ( ! this . config . tempdir ) {
853+ throw new Error ( "No tempdir specified" ) ;
854+ }
855+ const ipaOut = getOutputPath ( this . config . tempdir , this . config . outfile ! ) ;
851856 try {
852857 fs . unlinkSync ( ipaOut ) ; // await for it
853858 } catch ( e ) {
854859 /* do nothing */
855860 }
856861 this . events . emit ( "message" , "Zipifying into " + ipaOut + " ..." ) ;
857862 const rootFolder = this . config . payloadOnly ? "Payload" : "." ;
858- await tools . zip ( this . config . outdir , ipaOut , rootFolder ) ;
863+ await tools . zip ( this . config . tempdir , ipaOut , rootFolder ) ;
859864 if ( this . config . replaceipa ) {
860865 this . events . emit ( "message" , "mv into " + ipaIn ) ;
861866 fs . rename ( ipaOut , ipaIn ) ;
@@ -865,23 +870,23 @@ class Applesign {
865870 setFile ( name : any ) {
866871 fchk ( arguments , [ "string" ] ) ;
867872 this . config . file = path . resolve ( name ) ;
868- this . config . outdir = this . config . file + "." + uuid . v4 ( ) ;
873+ this . config . tempdir ?? = this . config . file + "." + uuid . v4 ( ) ;
869874 if ( ! this . config . outfile ) {
870875 this . config . outfile = getResignedFilename ( this . config . file ) ;
871876 }
872877 }
873878
874- async unzipIPA ( file : any , outdir : any ) : Promise < any > {
879+ async unzipIPA ( file : any , workdir : any ) : Promise < any > {
875880 fchk ( arguments , [ "string" , "string" ] ) ;
876- if ( ! file || ! outdir ) {
881+ if ( ! file || ! workdir ) {
877882 throw new Error ( "No output specified" ) ;
878883 }
879- if ( ! outdir ) {
884+ if ( ! workdir ) {
880885 throw new Error ( "Invalid output directory" ) ;
881886 }
882887 await this . cleanup ( ) ;
883888 this . events . emit ( "message" , "Unzipping " + file ) ;
884- return tools . unzip ( file , outdir ) ;
889+ return tools . unzip ( file , workdir ) ;
885890 }
886891
887892 /* Event Wrapper API with cb support */
@@ -994,7 +999,7 @@ function runScriptSync(script: string, session: any) {
994999 process . env . APPLESIGN_DIRECTORY = session . config . appdir ;
9951000 process . env . APPLESIGN_MAINBIN = session . config . appbin ;
9961001 process . env . APPLESIGN_OUTFILE = session . config . outfile ;
997- process . env . APPLESIGN_OUTDIR = session . config . outdir ;
1002+ process . env . APPLESIGN_TEMPDIR = session . config . tempdir || "" ;
9981003 process . env . APPLESIGN_FILE = session . config . file ;
9991004 try {
10001005 const res = execSync ( script ) ;
@@ -1020,7 +1025,7 @@ function nestedApp(file: string) {
10201025
10211026function getAppDirectory ( this : any , ipadir : string ) {
10221027 if ( ! ipadir ) {
1023- ipadir = path . join ( this . config . outdir , "Payload" ) ;
1028+ ipadir = path . join ( this . config . tempdir , "Payload" ) ;
10241029 }
10251030 if ( ! tools . isDirectory ( ipadir ) ) {
10261031 throw new Error ( "Not a directory " + ipadir ) ;
0 commit comments