From 56f3aca88080c9cb511da81c6ba8c1269c4858c8 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 21 Aug 2020 21:51:14 +0800 Subject: [PATCH] refactor(npm): musl target filename --- src/build.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/build.ts b/src/build.ts index 177685c4..4560ec9d 100644 --- a/src/build.ts +++ b/src/build.ts @@ -17,8 +17,8 @@ export class BuildCommand extends Command { @Command.String(`--name`) name!: string - @Command.String(`--platform`) - appendPlatformToFilename!: string + @Command.Boolean(`--platform`) + appendPlatformToFilename!: boolean @Command.Boolean(`--release`) isRelease = false @@ -82,10 +82,14 @@ export class BuildCommand extends Command { const targetDir = this.isRelease ? 'release' : 'debug' - const platformName = this.isMusl - ? '.musl' - : this.appendPlatformToFilename - ? `.${platform}` + if (this.isMusl && !this.appendPlatformToFilename) { + throw new TypeError(`Musl flag must be used with platform flag`) + } + + const platformName = this.appendPlatformToFilename + ? !this.isMusl + ? `.${platform}` + : `.${platform}-musl` : '' let distModulePath =