Skip to content

fix(cli): use npm run tauri -- foo for correctly passing args to tauri#6448

Merged
lucasfernog merged 2 commits intotauri-apps:nextfrom
meowtec:fix/npm-pass-args
Mar 16, 2023
Merged

fix(cli): use npm run tauri -- foo for correctly passing args to tauri#6448
lucasfernog merged 2 commits intotauri-apps:nextfrom
meowtec:fix/npm-pass-args

Conversation

@meowtec
Copy link
Contributor

@meowtec meowtec commented Mar 14, 2023

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

If use npm run tauri android init for generating Android project, we will get some error like this when run dev:

error: unexpected argument 'aarch64' found
Usage: npm run tauri android android-studio-script [OPTIONS]
For more information, try '--help'.

Executed commandis:

npm run  tauri android android-studio-script --target aarch64

NPM will consume argument --target, then pass android android-studio-script aarch64 to tauri.

When using npm, we should use -- for passing args into tauri.

Instead, we should use npm run tauri -- android android-studio-script --target aarch64.

The minimum case is npm run tauri -v which will output NPM version.

I have tested with pnpm and yarn,

Also see npm/npm#5518

@meowtec meowtec requested review from a team as code owners March 14, 2023 11:55
@meowtec meowtec changed the title fix(cli): use npm run tauri -- foo for correctly pass args to tauri fix(cli): use npm run tauri -- foo for correctly passing args to tauri Mar 14, 2023
@meowtec meowtec force-pushed the fix/npm-pass-args branch from b34406f to 0eb924d Compare March 14, 2023 12:04
```
yarn tauri dev
-or-
npm run tauri dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

# with yarn
$ yarn tauri dev
# with npm
$ npm run tauri dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

# with yarn
$ yarn tauri dev
# with npm
$ npm run tauri dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

# with yarn
$ yarn tauri dev
# with npm
$ npm run tauri dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@meowtec meowtec force-pushed the fix/npm-pass-args branch from 0eb924d to 40b2f49 Compare March 14, 2023 14:15
amrbashir
amrbashir previously approved these changes Mar 14, 2023
@FabianLars
Copy link
Member

Judging from this single example:

npm run tauri android android-studio-script --target aarch64

I don't think this is something that needs changes inside tauri right? Aren't we just talking about this:

npm run tauri android android-studio-script -- --target aarch64

(note the extra --)

I mean, this is an issue with all commands (including desktop ones) so wouldn't we just make it inconsistent with this change?

Sorry if i'm missing something obvious here.

@meowtec
Copy link
Contributor Author

meowtec commented Mar 14, 2023

@FabianLars Mobile is special:

Judging from this single example:

npm run tauri android android-studio-script --target aarch64

I don't think this is something that needs changes inside tauri right? Aren't we just talking about this:

npm run tauri android android-studio-script -- --target aarch64

(note the extra --)

I mean, this is an issue with all commands (including desktop ones) so wouldn't we just make it inconsistent with this change?

Sorry if i'm missing something obvious here.

For desktop, it is simple to add -- before arguments. (And there should be some alert / advice in docs, in the future)

But mobile platform is different: the command ...android-studio-script --target ... is automatically generated into Android project by android init command, and executed by gradle, not explicitly / manually. So it is required to change tauri's code.

@lucasfernog lucasfernog merged commit 1b343bd into tauri-apps:next Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants