Skip to content

Plugins don't get all the needed information... #2

Open

Description

@NathanaelA

When using the hook; plugins don't know if the hook is being targeted at ios or android. I'm having to parse the command line myself to pull this info out even though the nativescript command should have that information.

In addition the platform folder imho should be pointing to the actual platform that is being targetted; not the ./platforms folder, as I then have to create the entire path to where the ios or android build data resides.

Activity

  1. farfromrefug commented on Feb 2, 2019

    @farfromrefug

    @Fatme any news on this?
    Facing this issue too

  2. NathanaelA commented on Feb 2, 2019

    @NathanaelA
    Author
  3. Fatme commented on Feb 2, 2019

    @Fatme

    @farfromrefug,

    The first option is to use $options.argv._. It will return the full command line as array. After that you can search for ios or android item.

    module.exports = function ($options) {
        const commandLine = $options.argv._;
        const isiOSPlatform = commandLine.find(item => item.toLowerCase() === "ios");
    }
    

    The second option is to use $devicesService.platform but it will NOT work for all the commands and all the hooks.
    It will work only for device related commands (where device discovery is started) like tns run android, tns run ios, tns debug ios, tns debug anroid.
    It will not work for device related commands when the platform is not provided - for example tns run.
    It will not work for commands like tns preapre ios where device discovery is not started.

    module.exports = function ($devicesService) {
        const platform = $devicesService.platform;
    }
    
  4. farfromrefug commented on Feb 2, 2019

    @farfromrefug

    @Fatme @NathanaelA thanks for the explanations! I think I ll use the command line args.

  5. Fatme commented on Feb 3, 2019

    @Fatme

    @farfromrefug,

    The drawback of this approach is that it will not work when {N} CLI is used as library.

  6. farfromrefug commented on Feb 3, 2019

    @farfromrefug

    @Fatme when is it used as a library? sidekick?

  7. Fatme commented on Feb 3, 2019

    @Fatme

    @farfromrefug
    Yes, sidekick

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions