Skip to content

Commit

Permalink
Merge pull request #13 from zephraph/bug
Browse files Browse the repository at this point in the history
calculate zip filename in constructor so it's picked up by upload-asset-plugin
  • Loading branch information
hipstersmoothie authored Feb 21, 2021
2 parents 7acef86 + ac60658 commit fe3ae24
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/auto-plugin-obsidian/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,18 @@ export default class ObsidianPlugin implements IPlugin {
this.main = path.join(dir, "main.js");
this.manifest = path.join(process.cwd(), "manifest.json");
this.versions = path.join(process.cwd(), "versions.json");
this.zip = glob.sync(path.join(dir, "*.zip"))[0];

if (!fs.existsSync(this.manifest)) {
throw new Error(`Could not find file "${this.manifest}"`);
}

const manifest = JSON.parse(fs.readFileSync(this.manifest, "utf-8"));
const zipFilename = `${manifest.id}.zip`;

this.zip =
this.dir === process.cwd()
? zipFilename
: path.join(this.dir, zipFilename);
}

/** Tap into auto plugin points. */
Expand Down Expand Up @@ -73,11 +84,6 @@ export default class ObsidianPlugin implements IPlugin {
process.exit(1);
}

if (!fs.existsSync(this.manifest)) {
auto.logger.log.error(`Could not find file "${this.manifest}"`);
process.exit(1);
}

if (!fs.existsSync(this.versions)) {
auto.logger.log.error(`Could not find file "${this.versions}"`);
process.exit(1);
Expand Down Expand Up @@ -158,18 +164,16 @@ export default class ObsidianPlugin implements IPlugin {
return;
}

const manifest = JSON.parse(fs.readFileSync(this.manifest, "utf-8"));

if (this.dir === process.cwd()) {
const files = [this.manifest, this.main];

if (fs.existsSync(this.styles)) {
files.push(this.styles);
}

await execPromise("zip", [`${manifest.id}.zip`, ...files]);
await execPromise("zip", [this.zip, ...files]);
} else {
await execPromise("zip", ["-r", `${manifest.id}.zip`, this.dir]);
await execPromise("zip", ["-r", this.zip, this.dir]);
}
});

Expand Down

0 comments on commit fe3ae24

Please sign in to comment.