From 8700da17763ed5c9fd5ddda8f7a8af4d922ecbed Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 1 Apr 2022 17:07:53 +0800 Subject: [PATCH] fix(cli): should not throw if cargoName is provided but no package.name --- .github/workflows/cli-binary.yml | 7 +++++++ cli/src/build.ts | 2 ++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/cli-binary.yml b/.github/workflows/cli-binary.yml index 29625465..bd304067 100644 --- a/.github/workflows/cli-binary.yml +++ b/.github/workflows/cli-binary.yml @@ -51,6 +51,13 @@ jobs: env: RUST_BACKTRACE: 1 + - name: Pass -p and --cargo-name to build + run: | + node ./cli/scripts/index.js build -p napi-examples-binary --cargo-name napi-examples-binary + ./napi-examples-binary + env: + RUST_BACKTRACE: 1 + - name: Clear the cargo caches run: | cargo install cargo-cache --no-default-features --features ci-autoclean diff --git a/cli/src/build.ts b/cli/src/build.ts index bd4b231d..12c8cfd0 100644 --- a/cli/src/build.ts +++ b/cli/src/build.ts @@ -204,6 +204,8 @@ export class BuildCommand extends Command { let cargoPackageName: string if (tomlContent.package?.name) { cargoPackageName = tomlContent.package.name + } else if (this.cargoName) { + cargoPackageName = this.cargoName } else { throw new TypeError('No package.name field in Cargo.toml') }