Skip to content

Commit a848611

Browse files
committed
Build: Make the sed usage portable across Linux & macOS
On macOS (which uses the BSD-variant of sed), the `-i` flag requires its “backup extension” to come immediately after the i (with a space), even if it’s empty; this made the release `sed` commands fail on macOS. The GNU sed doesn’t require an extension but it allows it. To make the commands work both on macOS & Linux, make the following changes: 1. Always specify the backup extension. 2. Explicitly specify the script part by using the `-e` flag. 3. To simplify the patterns, use `|` as a separator instead of `/`; then slashes don't need to be escaped in the script parts.
1 parent 3f79644 commit a848611

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

.release-it.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = {
1111
hooks: {
1212
"before:init": "bash ./build/release/pre-release.sh",
1313
"after:version:bump":
14-
"sed -i 's/main\\/AUTHORS.txt/${version}\\/AUTHORS.txt/' package.json",
14+
"sed -i '' -e 's|main/AUTHORS.txt|${version}/AUTHORS.txt|' package.json",
1515
"after:bump": "cross-env VERSION=${version} npm run build:all",
1616
"before:git:release": "git add -f dist/ dist-module/ changelog.md",
1717
"after:release": "echo 'Run the following to complete the release:' && " +

build/release/post-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ git push --follow-tags
4343
cd -
4444

4545
# Restore AUTHORS URL
46-
sed -i "s/$1\/AUTHORS.txt/main\/AUTHORS.txt/" package.json
46+
sed -i '' -e "s|$1/AUTHORS.txt|main/AUTHORS.txt|" package.json
4747
git add package.json
4848

4949
# Remove built files from tracking.

0 commit comments

Comments
 (0)