You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Sergey Shakhnazarov (JIRA)" <ji...@apache.org> on 2016/08/15 15:45:20 UTC
[jira] [Commented] (CB-11687) platform-specific plugin prepare
hooks should be run even when no platforms are specified
[ https://issues.apache.org/jira/browse/CB-11687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15421154#comment-15421154 ]
Sergey Shakhnazarov commented on CB-11687:
------------------------------------------
When {{prepare()}} is called without options we [initialize {{options.platforms}} with {{\[\]}}|https://github.com/apache/cordova-lib/blob/2a178662acfad9c779114fddd815e484fc1b6f1d/cordova-lib/src/cordova/prepare.js#L40] so that {{hooksRunner.fire('before_prepare'}} -> [{{scriptsFinder}} platform filter|https://github.com/apache/cordova-lib/blob/2a178662acfad9c779114fddd815e484fc1b6f1d/cordova-lib/src/hooks/scriptsFinder.js#L73] returns no platform-specific hooks.
After restoring platforms in [restore.installPlatformsFromConfigXML|https://github.com/apache/cordova-lib/blob/2a178662acfad9c779114fddd815e484fc1b6f1d/cordova-lib/src/cordova/prepare.js#L46] we call [cordova_util.preProcessOptions|https://github.com/apache/cordova-lib/blob/2a178662acfad9c779114fddd815e484fc1b6f1d/cordova-lib/src/cordova/prepare.js#L49], which [populates options.platforms with platforms list installed in the project|https://github.com/apache/cordova-lib/blob/2a178662acfad9c779114fddd815e484fc1b6f1d/cordova-lib/src/cordova/util.js#L278].
This causes {{hooksRunner.fire('after_prepare'}} to be called with populated {{options.platforms}} - that's why the [test is passing|https://github.com/apache/cordova-lib/blob/2a178662acfad9c779114fddd815e484fc1b6f1d/cordova-lib/spec-cordova/prepare.spec.js#L139] (this is due to the issue https://github.com/jasmine/jasmine/issues/444, which is spy call arguments are references) even though the real call to {{before_prepare}} is missing both {{options.platforms}} and {{options.paths}}.
> platform-specific plugin prepare hooks should be run even when no platforms are specified
> -----------------------------------------------------------------------------------------
>
> Key: CB-11687
> URL: https://issues.apache.org/jira/browse/CB-11687
> Project: Apache Cordova
> Issue Type: Bug
> Components: CordovaLib
> Reporter: Sergey Shakhnazarov
> Assignee: Sergey Shakhnazarov
>
> plugin.xml:
> {code}
> <platform name="windows">
> <hook type="before_build" src="hooks/windows/hook.js"/>
> <hook type="before_prepare" src="hooks/windows/hook.js"/>
> <hook type="after_build" src="hooks/windows/hook.js"/>
> <hook type="after_prepare" src="hooks/windows/hook.js"/>
> {code}
> hook.js:
> {code}
> module.exports = function(context) {
> console.log('context.hook: ' + context.hook);
> }
> {code}
> {{cordova prepare --verbose | findstr "context.hook"}} # no hooks runs
> {{cordova build --verbose | findstr "context.hook"}} # before_build, before_prepare, after_prepare, after_build runs
> Expected - {{cordova prepare}} should run plugin' platform-specific hooks as well.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org