cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rakatyal <...@git.apache.org>
Subject [GitHub] cordova-docs pull request: CB-10353: Make Hooks guide a reference
Date Fri, 05 Feb 2016 20:07:19 GMT
Github user rakatyal commented on a diff in the pull request:

    https://github.com/apache/cordova-docs/pull/489#discussion_r52066234
  
    --- 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.: org.apache.cordova.file, org.apache.cordova.file-transfer)
    --- End diff --
    
    cordova-plugin-file-transfer, cordova-plugin-file


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message