cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-10353) Make Hooks guide a reference
Date Fri, 05 Feb 2016 22:15:40 GMT

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

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

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

    https://github.com/apache/cordova-docs/pull/489#discussion_r52080114
  
    --- Diff: www/docs/en/dev/guide/appdev/hooks/index.md ---
    @@ -178,28 +307,51 @@ module.exports = function(context) {
     `context.opts.plugin` object will only be passed to plugin hooks scripts.
     
     You can also require additional Cordova modules in your script using `context.requireCordovaModule`
in the following way:
    +
     ```javascript
     var Q = context.requireCordovaModule('q');
     ```
     
    +You can make your scipts async using Q:
    +
    +```javascript
    +module.exports = function(context) {
    +    var Q = context.requireCordovaModule('q');
    +    var deferral = new Q.defer();
    +
    +    setTimeout(function(){
    +      console.log('hook.js>> end');
    +    deferral.resolve();
    +    }, 1000);
    +
    +    return deferral.promise;
    +}
    +```
    +
    +
    +
     __Note__:  new module loader script interface is used for the `.js` files defined via
`config.xml` or `plugin.xml` only.
     For compatibility reasons hook files specified via `/hooks` folders are run via Node
child_process spawn, see 'Non-javascript' section below.
     
     ### Non-javascript
     
    -__Note__: we highly recommend writing your hooks using Node.js so that they are cross-platform,
see 'Javascript' section above.
    -
     Non-javascript scripts are run via Node child_process spawn from the project's root directory
and have the root directory passes as the first argument. All other options are passed to
the script using environment variables:
     
    -* CORDOVA_VERSION - The version of the Cordova-CLI.
    -* CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.:
android, ios).
    -* CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.:
org.apache.cordova.file, org.apache.cordova.file-transfer)
    -* CORDOVA_HOOK - Path to the hook that is being executed.
    -* CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova
run ios --emulate)
    +Environment Variable Name     | Description
    +------------------------------|--------------------------------------------
    +CORDOVA_VERSION               | The version of the Cordova-CLI.
    +CORDOVA_PLATFORMS             | Comma separated list of platforms that the command applies
to (e.g.: android, ios).
    +CORDOVA_PLUGINS               | Comma separated list of plugin IDs that the command applies
to (e.g.: cordova-plugin-file-transfer, cordova-plugin-file)
    +CORDOVA_HOOK                  | Path to the hook that is being executed.
    +CORDOVA_CMDLINE               | The exact command-line arguments passed to cordova (e.g.:
cordova run ios --emulate)
     
     If a script returns a non-zero exit code, then the parent cordova command will be aborted.
     
    -Also, note that even if you are working on Windows, and in case your hook scripts aren't
bat files (which is recommended, if you want your scripts to work in non-Windows operating
systems) Cordova CLI will expect a shebang line as the first line for it to know the interpreter
it needs to use to launch the script. The shebang line should match the following example:
    +__Note__: we highly recommend writing your hooks using Node.js so that they are cross-platform,
see [Javascript](#link-javascript) section above.
    +
    +#### Windows Quirks
    +
    +If you are working on Windows, and in case your hook scripts aren't bat files (which
is recommended, if you want your scripts to work in non-Windows operating systems) Cordova
CLI will expect a shebang line as the first line for it to know the interpreter it needs to
use to launch the script. The shebang line should match the following example:
    --- End diff --
    
    This sentence reads awkwardly and should be rephrased.


> Make Hooks guide a reference
> ----------------------------
>
>                 Key: CB-10353
>                 URL: https://issues.apache.org/jira/browse/CB-10353
>             Project: Apache Cordova
>          Issue Type: Task
>          Components: Docs
>            Reporter: Raghav
>            Assignee: Sarangan Rajamanickam
>              Labels: Docs-6.x
>
> Hooks guide (https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/index.html)
needs to be modified as per the reference structure. 
> General guidelines:
> - While giving examples, keep them short. Do not repeat for all plugins/platforms.
> - Remove all references to cordova plugin registry.
> - Remove Tizen references. The platform is deprecated (http://markmail.org/message/hryg6sjswecpgndu)
> - Keep information up to date for the platforms, CLI and plugins



--
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


Mime
View raw message