tajinder-logiciel opened a new issue #857:
URL: https://github.com/apache/cordova-lib/issues/857
# Bug Report
## Problem
I am using hooks in my cordova project but in hooks Process.env variables
are not working
### What is expected to happen?
Just want to use process.env variables in my hooks file before when Hooks
dir is working for running hooks, environment variables were working
## Information
Have added hooks in config.xml
```
<platform name="ios">
<hook src="hooks/before_prepare/set_codepush_key.js"
type="before_prepare" />
<hook src="hooks/after_prepare/010_add_platform_class.js"
type="after_prepare" />
<hook src="hooks/after_prepare/020_remove_sass_from_platforms.js"
type="after_prepare" />
<hook
src="hooks/after_prepare/030_clean_dev_files_from_platforms.js"
type="after_prepare" />
<hook src="hooks/after_prepare/040_move_dist_files_to_platforms.js"
type="after_prepare" />
<hook src="hooks/after_prepare/050_clean_obfuscation.js"
type="after_prepare" />
<hook src="hooks/after_prepare/060_uglify.js" type="after_prepare" />
</platform>
```
After prepare hooks are working but in the hooks file, environment variables
are not working
### Command or Code
these two environment variables were used in my hook file
```
var platforms = process.env.CORDOVA_PLATFORMS.split(',');
var cliCommand = process.env.CORDOVA_CMDLINE;
```
`/Users/username/.nvm/versions/node/v12.18.4/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js`
In this file, there are two functions
```
runScriptViaModuleLoader
runScriptViaChildProcessSpawn
```
In **runScriptViaModuleLoader** function, there is no code to set
Environment variables and this function is called in these hooks but in the
other function **runScriptViaChildProcessSpawn** Environment variables code is
there but not called for these hooks
So can anyone help me regarding this
### Version information
Cordova 10.0.0
node 12.18.4
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]