build: use uname instead of relying on sed --version (#28900)
PR Close #28900
This commit is contained in:
parent
3cc9ba24c6
commit
f4d652568d
|
@ -1,7 +1,20 @@
|
||||||
# sedi makes sed work on both OSX & Linux
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eux -o pipefail
|
||||||
|
# -e: exits if a command fails
|
||||||
|
# -u: errors if an variable is referenced before being set
|
||||||
|
# -x: shows the commands that get run
|
||||||
|
# -o pipefail: causes a pipeline to produce a failure return code if any command errors
|
||||||
|
|
||||||
|
# sedi makes `sed -i` work on both OSX & Linux
|
||||||
# See https://stackoverflow.com/questions/2320564/i-need-my-sed-i-command-for-in-place-editing-to-work-with-both-gnu-sed-and-bsd
|
# See https://stackoverflow.com/questions/2320564/i-need-my-sed-i-command-for-in-place-editing-to-work-with-both-gnu-sed-and-bsd
|
||||||
sedi () {
|
sedi () {
|
||||||
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@"
|
case $(uname) in
|
||||||
|
Darwin*) sedi=('-i' '') ;;
|
||||||
|
*) sedi='-i' ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
sed "${sedi[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
sedi "s#packages-dist:#file://$PWD/../../dist/packages-dist/#" src/package.json
|
sedi "s#packages-dist:#file://$PWD/../../dist/packages-dist/#" src/package.json
|
||||||
|
|
Loading…
Reference in New Issue