Skip to content

Capacitor commands don't respect integration root directory override #4526

Description

@eweap

Hello,

I've tried to run ionic capacitor run android -l --external but found out that it calls capacitor add android even if android platform is already installed and configured (and it fails because, android in already installed).

Then I found that there is a checkForPlatformInstallation(platform: string) call that happens in the command pre-run

The problem is at this line, when we try to retrieve the capacitor integration root:

const integrationRoot = this.project.directory;

in my case the capacitor integration root was overrided to point in a another subdirectory in ionic.config.json:

{
    "defaultProject": "app-mobile",
    "projects": {
        "app-mobile": {
            "name": "App mobile",
            "type": "angular",
            "id": "MY_ID",
            "npmClient": "yarn",
            "root": "apps/app-mobile",
            "integrations": {
                "capacitor": {
                    "root": "integrations/app-mobile/capacitor"
                }
            }
        }
    }
}

I think that the capacitor integration root should be retrieve this way:

const integrationRoot = this.project.getIntegration('capacitor').root;

It looks like to work in both case, when root is overrided or not.

I don't know if we must replace the others calls to this.project.directory in the ionic-cli/packages/@ionic/cli/src/commands/capacitor/base.ts file ?

Let me know if you're interrested in a pull request with a fix.

Thanks !

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions