I’m implementing a Hook in before_prepare
and I need to pass a parameter to my command. Only I realized that the parameter was not being sent to the cordova, not getting into my script, then removes the ionic from the command and the parameter arrives in the script correctly.
Here’s what’s happening:
config.xml
:
// ...
<hook src="hooks/build-environment-config.js" type="before_prepare" />
// ...
hooks/build-environment-config.js
:
module.exports = function (ctx) {
console.log(ctx.opts.options);
console.log(ctx.cmdLine);
};
Outputs:
$ cordova prepare android --flavor=dev
{ flavor: 'dev', argv: [], fetch: true }
C:\Program Files\nodejs\node.exe C:\Users\Usuario\AppData\Roaming\npm\node_modules\cordova\bin\cordova prepare android --flavor=dev
$ ionic cordova prepare android --flavor=dev
> cordova prepare android
{ argv: [], fetch: true }
C:\Program Files\nodejs\node.exe C:\Users\Usuario\AppData\Roaming\npm\node_modules\cordova\bin\cordova prepare android
What can I do so I can perform the command with ionic and pass the parameter to the cordova hook script?
Environment:
Ionic CLI: 3.13.2
Cordova: 7.1.0