From a3a3d289c527f07eb842e5aac75d732c05259ef7 Mon Sep 17 00:00:00 2001 From: Northword Date: Sun, 31 Mar 2024 15:28:38 +0800 Subject: [PATCH] fix: xpiname undefined --- src/config.ts | 1 + src/lib/base.ts | 2 +- src/lib/build.ts | 4 ++-- src/types/index.ts | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/config.ts b/src/config.ts index b2b60ad..8337263 100644 --- a/src/config.ts +++ b/src/config.ts @@ -55,6 +55,7 @@ function resolveConfig(config: Config): Context { const ctx: Context = { ...config, pkgUser: pkg, + xpiName: dash(config.name), version: pkg.version, hooks: createHooks(), templateDate: data, diff --git a/src/lib/base.ts b/src/lib/base.ts index f4b49e7..747fa8c 100644 --- a/src/lib/base.ts +++ b/src/lib/base.ts @@ -40,6 +40,6 @@ export abstract class Base { return this.ctx.updateURL; } get xpiName() { - return this.ctx.build.define.xpiName; + return this.ctx.xpiName; } } diff --git a/src/lib/build.ts b/src/lib/build.ts index dbbbc60..5b07837 100644 --- a/src/lib/build.ts +++ b/src/lib/build.ts @@ -233,7 +233,7 @@ export default class Build extends Base { max = manifest.applications?.zotero?.strict_max_version; const updateHash = generateHashSync( - path.join(this.dist, `${this.ctx.templateDate.xpiName}.xpi`), + path.join(this.dist, `${this.xpiName}.xpi`), "sha512", ); @@ -278,7 +278,7 @@ export default class Build extends Base { await webext.cmd.build({ sourceDir: `${this.dist}/addon`, artifactsDir: this.dist, - filename: `${this.ctx.templateDate.xpiName}.xpi`, + filename: `${this.xpiName}.xpi`, overwriteDest: true, }); } diff --git a/src/types/index.ts b/src/types/index.ts index 1158c79..a7b7775 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -21,6 +21,7 @@ interface UserConfig extends RecursivePartial { interface Context extends Config { pkgUser: any; + xpiName: string; version: string; hooks: Hookable; templateDate: { [placeholder: string]: string };