Sn0opr
Sn0opr

Reputation: 1026

Cordova hook not running when using modules.exports function

I created an after_prepare hook :

#!/usr/bin/env node

module.exports = function(context) {
    ... some code
  console.log('Hey, a hook');
}

When I run cordova build android, I see in the terminal that it says it is running my hook but it seems like it's not running the module.exports function, because the console.log isn't shown in the console.

Upvotes: 6

Views: 2435

Answers (1)

likerRr
likerRr

Reputation: 1296

I solved this!

I added hook to the config.xml file

<hook type="after_prepare" src="hooks/after_prepare/020_add_android_permissions.js"/>

and now it executes the code under the module.exports function.

Update: here is the working example

Upvotes: 5

Related Questions