0

I have a Cordova hook that executes after execution of build command. And one hook which executes before build command is executed.

I want it to executes only if --release attribute is added in build command.

Is it possible? As I am doing something in hook (i.e. changing version code of builds.) which I want to do only for release builds.

Please ask if something is unclear to you.

Yawar
  • 1,924
  • 3
  • 29
  • 39
  • i have wrote a similar hook earlier but not exactly the same. That was to parameterize the app id to install facebook plugin. You can follow the similar sample to address. These links should help you out - https://stackoverflow.com/questions/28304156/in-my-cordova-app-how-do-i-get-the-version-string-i-defined-in-the-config-xml/42650842#42650842 and https://github.com/gandhirajan/Cordova_Hooks May be in your case you gotta set release attribute as environment variable before every run – Gandhi Jul 06 '17 at 07:55
  • I think using Target env variable is what I need. – Yawar Jul 06 '17 at 08:03
  • you are right. That should do the trick for you. Posted the answer. Cheers – Gandhi Jul 06 '17 at 08:07
  • SET TARGET=i && ionic cordova build ios --device --release – Yawar Jul 06 '17 at 08:07
  • above commmand says there is no SET : command found – Yawar Jul 06 '17 at 08:08
  • even run without && but still same error – Yawar Jul 06 '17 at 08:09
  • set is the normal windows command we use to add env variable. https://www.computerhope.com/sethlp.htm – Gandhi Jul 06 '17 at 08:13
  • I am on mac system – Yawar Jul 06 '17 at 08:14
  • check this post for non windows based solution - https://stackoverflow.com/questions/37816035/using-environment-variables-parameterizing-config-xml/38475946#38475946 – Gandhi Jul 06 '17 at 08:22
  • u got it through? – Gandhi Jul 06 '17 at 10:44
  • Yes you can add in your answer that on mac there is no need to write set just (TARGET=a ionic cordova build ios ....) will work – Yawar Jul 06 '17 at 10:47
  • updated the answer. Please accept and vote. thanks – Gandhi Jul 06 '17 at 11:06

1 Answers1

1

I wrote a similar hook sometime back but not exactly the same. That was to parameterize the app id to install facebook plugin. You can follow the similar approach to address your issue too.

These links should help you out - SO post on hook and sample hook github repo. May be in your case you gotta set the release attribute as environment variable before every build instead of passing it as an build attribute. Hope it helps.

UPDATE: For mac OS, you can set environmental variables in the user directories .bash_profile

Gandhi
  • 11,875
  • 4
  • 39
  • 63