问题
I am having issues with the pre-build script on appcenter. Appcenter uses bash for the pre-build scripts. I want to change "qa.api" to "beta.api" in my api.js file.
I tried the following but it does not seem to work:
#!/usr/bin/env bash
if [ "$APPCENTER_BRANCH" != "master" ];
then
cd App/Services/
echo "changing QA API to Production API (beta)"
sed -i 's/qa.api/beta.api/g' Api.js
fi
So I simplified it but it still does not work:
#!/usr/bin/env bash
cd App/Services/
sed -i 's/qa.api/beta.api/g' Api.js`
Any ideas?
回答1:
sed's -i
option takes a parameter to indicate what extension to add to the file name when making a backup. Unlike linux versions, on macOS, this extension parameter is required.
Try to provide an empty string here:
sed -i '' 's/qa.api/beta.api/g' Api.js
来源:https://stackoverflow.com/questions/51694801/bash-scripting-error-on-microsoft-appcenter-for-pre-build-script