I am on a windows machine with vscode and run commands from bash terminal inside it. However have found that the firebase deploy
cli is more stable on my machine if called from cmd or powershell. Sometimes hangs with vscode.bash or gitbash terminal.
I have my cloud functions in typescript, and the firebase deploy --only functions
runs the predeploy script e.g. npm run build
I have changed my npm build script to "build": "tsc && npm run copyKeys",
so that it will always ensure changes to keys are copied before deploying. The keys are service account keys which are used by during the deployment.
The copyKeys script is "copyKeys": "cp -rf ./src/environments/service.acct.keys/ ./lib/environments/",
this works nicely in bash.
But I need to a second xcopyKeys4Win script for when using powershell which becomes "xcopyKeys4Win": "XCOPY .\\src\\environments\\service.acct.keys .\\lib\\environments\\service.acct.keys /s /e /y /i"
which works nicely from PS.
Now my issue is the when I call npm run deploy
, this calls firebase deploy --only functions
that runs the firebase predeploy scripts which call the npm run build
and this build script is hard-coded to either ... npm run copyKeys
or ... npm run xcopyKeys4Win
.
I need someway to conditionally call 'npm run deploy' depending on whether needing bash cp e.g. on mac/linux/vscode.bash/gitbash, or xcopy if using cmd or PS.
E.g. either something similar to firebase hosting target setting or condition in the npm build script or something else, anyone got any ideas?