Skip to content

Commit

Permalink
Make the init tool compatible with BSD
Browse files Browse the repository at this point in the history
  • Loading branch information
cotes2020 committed Sep 29, 2021
1 parent 95b4b45 commit 6a4169f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set -eu

ACTIONS_WORKFLOW=pages-deploy.yml

TEMP_SUFFIX="to-delete" # temporary file suffixes that make `sed -i` compatible with BSD and Linux

help() {
echo "Usage:"
echo
Expand Down Expand Up @@ -61,12 +63,15 @@ init_files() {
_workflow=".github/workflows/${ACTIONS_WORKFLOW}"
_default_branch="$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
_lineno="$(sed -n "/branches:/=" "$_workflow")"
sed -i "$((_lineno + 1))s/- .*/- ${_default_branch}/" "$_workflow"

sed -i.$TEMP_SUFFIX "$((_lineno + 1))s/- .*/- ${_default_branch}/" "$_workflow"
rm -f "$_workflow.$TEMP_SUFFIX"

fi

# trace the gem lockfile on user-end
sed -i "/Gemfile.lock/d" .gitignore
sed -i.$TEMP_SUFFIX "/Gemfile.lock/d" .gitignore
rm -f ".gitignore.$TEMP_SUFFIX"

# remove the other fies
rm -f .travis.yml
Expand Down

0 comments on commit 6a4169f

Please sign in to comment.