Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ class Applesign {
throw new Error("No tempdir specified");
}
await this.unzipIPA(this.config.file, this.config.tempdir);
const appDirectory = path.join(this.config.tempdir, "/Payload");
this.config.appdir = getAppDirectory(appDirectory);
this.config.appdir = getAppDirectory(
getPayloadDirectory(this.config.tempdir),
);
if (this.config.debug) {
this.debugObject = {};
}
Expand All @@ -126,7 +127,7 @@ class Applesign {
if (tasks.length > 0) {
await Promise.all(tasks);
}
await this.signAppDirectory(appDirectory);
await this.signAppDirectory(this.config.appdir);
await this.zipIPA();
} finally {
await this.cleanup();
Expand Down Expand Up @@ -1023,28 +1024,27 @@ function nestedApp(file: string) {
return false;
}

function getAppDirectory(this: any, ipadir: string) {
if (!ipadir) {
ipadir = path.join(this.config.tempdir, "Payload");
function getPayloadDirectory(tempdir?: string): string {
if (!tempdir) {
throw new Error("No tempdir specified");
}
if (!tools.isDirectory(ipadir)) {
throw new Error("Not a directory " + ipadir);
return path.join(tempdir, "Payload");
}

function getAppDirectory(directory: string): string {
if (!tools.isDirectory(directory)) {
throw new Error("Not a directory " + directory);
}
if (ipadir.endsWith(".app")) {
this.config.appdir = ipadir;
} else {
const files = fs.readdirSync(ipadir).filter((x: string) => {
return x.endsWith(".app");
});
if (files.length !== 1) {
throw new Error("Invalid IPA: " + ipadir);
}
return path.join(ipadir, files[0]);
if (directory.endsWith(".app")) {
return directory;
}
if (ipadir.endsWith("/")) {
ipadir = ipadir.substring(0, ipadir.length - 1);
const files = fs.readdirSync(directory).filter((x: string) => {
return x.endsWith(".app");
});
if (files.length !== 1) {
throw new Error("Invalid IPA: " + directory);
}
return ipadir;
return path.join(directory, files[0]);
}

async function enumerateTestFiles(dir: string): Promise<string[]> {
Expand Down
2 changes: 1 addition & 1 deletion lib/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const version = "5.0.1";
const version = "6.0.0";
export default version;
Loading