Skip to content

Commit

Permalink
Make release sed command work on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanTAllen committed Mar 11, 2017
1 parent ed559be commit 362d1d0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ update_changelog() {

local match='## \[unreleased\] \- unreleased'
local heading="## [$version] - $release_date"
sed -i "/$match/c $heading" CHANGELOG.md
case $OSTYPE in
darwin*)
sed -i '' -E "/$match/c $heading" CHANGELOG.md;;
*)
sed -i "/$match/c $heading" CHANGELOG.md;;
esac
}

remove_empty_sections() {
Expand All @@ -36,15 +41,25 @@ remove_empty_sections() {
local first_word=`echo $str_after | head -n1 | cut -d " " -f1`
if [ $first_word != "-" ]; then
echo "Removing empty CHANGELOG section: $section"
sed -i "0,/### $section/{//d;}" CHANGELOG.md
case $OSTYPE in
darwin*)
sed -i '' -E "0,/### $section/{//d;}" CHANGELOG.md;;
*)
sed -i "0,/### $section/{//d;}" CHANGELOG.md;;
esac
fi
done
}

add_changelog_unreleased_section() {
echo "Adding unreleased section to CHANGELOG"
local replace='## [unreleased] - unreleased\n\n### Fixed\n\n\n### Added\n\n\n### Changed\n\n\n'
sed -i "/## \[$version\] \- $release_date/i $replace" CHANGELOG.md
case $OSTYPE in
darwin*)
sed -i '' -E "/## \[$version\] \- $release_date/i $replace" CHANGELOG.md;;
*)
sed -i "/## \[$version\] \- $release_date/i $replace" CHANGELOG.md;;
esac
}


Expand Down

0 comments on commit 362d1d0

Please sign in to comment.