6

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.

1
  • Have you solved this issue? I faced the same problem and haven't found a solution yet.
    – likerRr
    Commented Jul 25, 2016 at 19:26

1 Answer 1

5

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

1
  • 1
    from official documentation hooks directory is deprecated and: > When using these hooks, they will always be run as executable files, not as loadable JavaScript modules.
    – Jack Lu
    Commented Aug 29, 2017 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.