hooks - GarthDB/phonegap-day-workshop-beginner GitHub Wiki

PhoneGap Hooks

Task hooks to do almost anything you need.

Table of Contents

  1. Usage
  2. Example

PhoneGap hooks allow you to run custom scripts before and/or after almost any command. This can become a powerful way to extend PhoneGap in ways that it does not yet support, such as moving around artifacts or linking into a continuous integration system.

Usage

You can read the full usage details in:

phonegap-app-pgday/hooks/README.md

Example

Let's create a simple example that outputs a message before listing your plugins.

  1. Open the directory phonegap-app-pgday

  2. Create the directory hooks/before_plugin_ls

  3. Create the file hooks/before_plugin_ls/echo.js

  4. Add the following to the file:

     #!/usr/bin/env node
     
     console.log('Give me a minute...');
    
  5. Make the file executable:

  • OS X and Linux: type the command $ chmod +x hooks/before_plugin_list/echo.js
  • Windows: right-click and select Properties then update the permissions for all users.
  1. Type $ phonegap plugin list

     Give me a minute...
     [phonegap] no plugins installed
    

That's it!