[ 
https://issues.apache.org/jira/browse/CB-12705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15986014#comment-15986014
 ] 

ASF GitHub Bot commented on CB-12705:
-------------------------------------

Github user feichngr commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/549#discussion_r113615881
  
    --- Diff: cordova-lib/src/hooks/HooksRunner.js ---
    @@ -178,7 +178,9 @@ function runScriptViaModuleLoader(script, context) {
         }
         var scriptFn = require(script.fullPath);
         context.scriptLocation = script.fullPath;
    -    context.opts.plugin = script.plugin;
    +    if(script.plugin) {
    +        context.opts.plugin = script.plugin;
    --- End diff --
    
    Yes and no. cordova-lib/src/plugman/install.js already populates 
`opts.plugin` before it is passed to `HooksRunner`.
    What currently happens in this code snippet is that the field is overridden 
with either information on the plugin which provides the script (i.e. the on in 
which `plugin.xml` it is defined) or `undefined` if the script is part of the 
project (i.e. defined in config.xml) because `script.plugin` is `undefined`.
    My change just prevents the override in the later case. The first case 
should behave as before so it doesn't break existing scripts.


> Project *_plugin_install hooks don't have information on installed plugin
> -------------------------------------------------------------------------
>
>                 Key: CB-12705
>                 URL: https://issues.apache.org/jira/browse/CB-12705
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: cordova-cli, CordovaLib
>    Affects Versions: 6.5.0
>            Reporter: Fabian Eichinger
>
> I want to build a {{after_plugin_install}} javascript hook for my project 
> that only executes it logic when installing a specific plugin (in my case 
> {{cordova-plugin-file}}). As it turns out the context passed to project-level 
> {{\*_plugin_install}} hooks do not contain *any* information on the plugin 
> that was installed and this makes these kind of hooks basically useless.
> I propose passing to them the same information in {{context.opts.plugin}} as 
> to plugin hooks.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to