cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Santana <csantan...@gmail.com>
Subject Can I have all my hooks in one file and be event driven?
Date Tue, 05 Aug 2014 20:18:48 GMT
I started to write hooks, and I got lazy :-)

What about having a single hook nodejs script that listen on cordova events?

My script will look something like this:

function worklightBeforePrepare(){
console.log('Running Worklight worklightBeforePrepare()');
}
function worklightAfterCompile(){
console.log('Running Worklight worklightAfterCompile()');
}
function worklightHooks(cordova_lib){
cordova_lib.events.on('before_prepare',worklightBeforePrepare);
cordova_lib.events.on('after_compile',worklightAfterCompile);
}
module.exports = {
run: worklightHooks
}


Then when cordova cli starts it always runs my hook script:

var script = path.join(root,'hook/global/worklight_cordova_hook.js');
var hook = require(script);
hook.run(cordova_lib);


-- 
Carlos Santana
<csantana23@gmail.com>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message