Skip to content

Commit

Permalink
ci: update bootstrap file
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser authored Jun 4, 2024
1 parent 1a2c33b commit cc6c7b6
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions BOOTSTRAP.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env zsh

set -e # abort when any command errors, prevents this script from self-removing at the end if anything went wrong
set -e # abort when any command errors, prevents self-removing at the end
#───────────────────────────────────────────────────────────────────────────────

# plugin name is the same as the git repo name and can therefore be inferred
repo=$(git remote -v | head -n1 | sed 's/\.git.*//' | sed 's/.*://')
repo=$(git remote -v | head -n1 | sed -e 's/\.git.*//' -e 's/.*:\(.*\) .*/\1/')
name=$(echo "$repo" | cut -d/ -f2)
name_short=$(echo "$name" | sed -e 's/.nvim$//' -e 's/^nvim-//')

Expand All @@ -16,13 +16,15 @@ year=$(date +"%Y")
#───────────────────────────────────────────────────────────────────────────────

LC_ALL=C # prevent byte sequence error
bootstrap_file=$(basename "$0")

# replace them all
# $1: placeholder name as {{mustache-template}}
# $2: the replacement
function replacePlaceholders() {
# INFO macOS' sed requires `sed -i ''`, remove the `''` when on Linux or using GNU sed
find . -type f -not -path '*/\.git/*' -not -name ".DS_Store" -exec sed -i '' "s/$1/$2/g" {} \;
find . -type f -not -path '*/\.git/*' -not -name ".DS_Store" -not -name "$bootstrap_file" -exec \
sed -i '' "s/$1/$2/g" {} \;
}

replacePlaceholders "%%plugin-name%%" "$name"
Expand All @@ -32,18 +34,15 @@ replacePlaceholders "%%plugin-name-short%%" "$name_short"

#───────────────────────────────────────────────────────────────────────────────
# Files

# Rename
mv "./lua/plugin-name.lua" "./lua/$name_short.lua"
mkdir ./lua

# for panvimdoc
mkdir -p ./doc/
mkdir ./doc
touch "./doc/$name_short.txt"

rm -- "$0" # make this script delete itself

#───────────────────────────────────────────────────────────────────────────────

git add --all && git commit -m "init: bootstrap"

print "\e[1;32mSuccess.\e[0m"

rm -- "$0" # make this script delete itself

0 comments on commit cc6c7b6

Please sign in to comment.