question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cordova prepare does not call platform prepare hooks

See original GitHub issue

If a prepare hook is defined in a platform block, it is not executed when cordova prepare is called without specifying a platform.

My expectation is that the platform prepare hooks will be still be called when a platform is not provided as an argument to the platform prepare command.

For example:

Given the following hook:

<platform name="android">
    <hook type="after_prepare" src="scripts/androidBeforeBuild.js" />
    ...
</platform>

When executing the command:

cordova prepare

the hook will not be found or executed.

However when executing the command:

cordova prepare android

the hook will be found and run as expected.

I have observed this for project and plugin hooks.

Is this behaviour by design? My thinking is that it is then always safer to run the platform prepare command with an explicit platform.

Thanks.

Collecting Data...


Node version: v8.10.0

Cordova version: 8.0.0

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
tombellcommented, Jan 16, 2019

Just encountered this behaviour today myself, while debugging a plugin which ultimately was due to me running cordova prepare not cordova prepare ios and wondering why a hook wasn’t running that the plugin should have run.

2reactions
dpoguecommented, Nov 14, 2018

I would also have expected all the hooks to run, and I don’t see anything in the docs to suggest otherwise, so this seems like it’s probably a bug (although it’s also likely that it has always behaved this way)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hooks Guide - Apache Cordova
Cordova Hooks represent special scripts which could be added by application and ... cordova run, To be executed before and after preparing your...
Read more >
VS2015 Build Not Executing node hooks and no errors
I notice that my hooks are called as expected if I call cordova prepare or cordova build from the command line, but when...
Read more >
Cordova Plugin - Hooks not firing - OutSystems
These hooks fire just fine when I build an app using cordova cli, but when I build the native app using Outsystems none...
Read more >
Running a Cordova Project in Android Studio - IBM
cordova prepare. This creates the mfpclient.properties file in the assets folder. If this file does not exist, you cannot run your app.
Read more >
cordova-uglify - npm
Once you have this hook installed it will compress your apps JavaScript and CSS when you run a cordova prepare <platform> or cordova...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found