Skip to content

Commit d8e359a

Browse files
committed
Await fs.rename in zipIPA and narrow unlink error handling
1 parent 8721565 commit d8e359a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,16 +854,18 @@ class Applesign {
854854
}
855855
const ipaOut = getOutputPath(this.config.tempdir, this.config.outfile!);
856856
try {
857-
fs.unlinkSync(ipaOut); // await for it
858-
} catch (e) {
859-
/* do nothing */
857+
await fs.unlink(ipaOut);
858+
} catch (err: any) {
859+
if (err?.code !== "ENOENT") {
860+
throw err;
861+
}
860862
}
861863
this.events.emit("message", "Zipifying into " + ipaOut + " ...");
862864
const rootFolder = this.config.payloadOnly ? "Payload" : ".";
863865
await tools.zip(this.config.tempdir, ipaOut, rootFolder);
864866
if (this.config.replaceipa) {
865867
this.events.emit("message", "mv into " + ipaIn);
866-
fs.rename(ipaOut, ipaIn);
868+
await fs.rename(ipaOut, ipaIn);
867869
}
868870
}
869871

0 commit comments

Comments
 (0)