Skip to content

Commit

Permalink
feat(hooks): add automatically adding version change
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Apr 13, 2023
1 parent 8e46095 commit 92c256b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/bash
flag_file_path='./.version-update'

if [ -f $flag_file_path ]; then
git add package.json package-lock.json public/manifest.json
git commit --amend --no-edit
fi

exit 0
18 changes: 12 additions & 6 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/bin/bash

flag_file_path='./.version-update'
# If this file exists when entering the script, it means the version was already
# updated and we did a commit amend to update package.json and package-lock.json,
# so we must delete the file and exit the script.
if [ -f $flag_file_path ]; then
rm $flag_file_path
exit 0
fi

npm run format
touch $flag_file_path

# types
commit_types='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)'
minor_types='^(build|feat|revert)'
Expand All @@ -11,12 +23,6 @@ msg=':\s.+'
version_match='"version": *"[0-9.]\+"'
version_str='"version": '

# skip with env
if [ "$SKIP_PRE_COMMIT" = true ]; then
echo 'Skipping conventional-pre-commit hook...'
exit 0
fi

# read message to var
commit_msg=$(cat $1)

Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Replace Maps iframes with OSM",
"author": "nobkd",
"license": "Unlicense",
"version": "1.0.1",
"version": "1.1.0",
"type": "module",
"homepage": "https://github.com/nobkd/replace-maps#readme",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "Replace Maps iframes with OSM",
"manifest_version": 2,
"name": "Replace Maps",
"version": "1.0.1",
"version": "1.1.0",
"homepage_url": "https://github.com/nobkd/replace-maps",
"icons": {
"48": "icons/48.png",
Expand Down

0 comments on commit 92c256b

Please sign in to comment.