apache / cordova-plugman

Apache Cordova Plugman
https://cordova.apache.org/
Apache License 2.0
400 stars 151 forks source link

CB-6481 adds plugin level hooks support #74

Closed sgrebnov closed 10 years ago

sgrebnov commented 10 years ago

1.Support of js script files only (nodejs is used to run script file)

2.Support of the following hook types

3.Use context argument to retrieve execution parameters inside hook function

module.exports = function(context) {
    console.log('hook.js>> platform: ' + context.platform);
    console.log('hook.js>> projectDir: ' + context.projectDir);
    console.log('hook.js>> pluginDir: ' + context.pluginDir);
    console.log('hook.js>> cmdLine: ' + context.cmdLine);

    var deferral = new Q.defer();

    setTimeout(function(){
        deferral.resolve();
    }, 1000);

    return deferral.promise;
}
sgrebnov commented 10 years ago

Created issue CB-6481 to cover this work. Switched to nodejs module loader. Sample hook file implementation with async functionality:

var Q = require('./q');

module.exports = function(context) {
    console.log('hook.js>> platform: ' + context.platform);
    console.log('hook.js>> projectDir: ' + context.projectDir);
    console.log('hook.js>> pluginDir: ' + context.pluginDir);
    console.log('hook.js>> cmdLine: ' + context.cmdLine);

    var deferral = new Q.defer();

    setTimeout(function(){
        deferral.resolve();
    }, 1000);

    return deferral.promise;
}
sgrebnov commented 10 years ago

Switched to single parameter called context

sgrebnov commented 10 years ago

@agrieve, thx for review; updated the code. Also did rebase

ligaz commented 10 years ago

Adding a couple of unit tests will be great :cop:

sgrebnov commented 10 years ago

Totally agree, will do as soon as cordova-lib work is stabilized so I can move the code to appropriate repo and perform final tests. @ligaz, thx for review.

sgrebnov commented 10 years ago

Moved to appropriate repo, closing... https://github.com/apache/cordova-lib/pull/12