From 1decb6c3355591677dcc422cde6813e0b31b3d20 Mon Sep 17 00:00:00 2001 From: Phillip Johnsen Date: Mon, 22 Feb 2021 13:11:01 +0100 Subject: [PATCH] Bump `mustache.js` version via npm script instead of git pre-commit hook Primarily because installing `git` hooks are easy to forget for maintainers, whilst telling `npm` to do something as a consequence of `$ npm version ` is seamless. Also worth mentioning we what we used to do in the pre-commit hook script is now greatly simplified as we don't want to have the build output and/or the `.min.js` in git anymore. Therefore, as long as we've bumped the version number in the source code, we're basically done, after having amended that change into the git commit the `npm` CLI creates. --- hooks/install-hooks.sh | 22 ------------------- package.json | 3 ++- .../bump-version-in-source | 14 ++---------- 3 files changed, 4 insertions(+), 35 deletions(-) delete mode 100755 hooks/install-hooks.sh rename hooks/pre-commit => scripts/bump-version-in-source (78%) diff --git a/hooks/install-hooks.sh b/hooks/install-hooks.sh deleted file mode 100755 index 422d24d..0000000 --- a/hooks/install-hooks.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -HOOK_NAMES="pre-commit" -HOOK_DIR=$(git rev-parse --show-toplevel)/.git/hooks -INSTALL_DIR=$(git rev-parse --show-toplevel)/hooks -COLOR_GREEN=`tput setaf 2` -COLOR_RESET=`tput sgr0` - -for hook in $HOOK_NAMES; do - echo -n "Installing $hook hook..." - # If the hook already exists, is executable, and is not a symlink - if [ ! -h $HOOK_DIR/$hook -a -x $HOOK_DIR/$hook ]; then - echo -n " Hook already exists, saving old hook backup at $HOOK_DIR/$hook.local..." - mv $HOOK_DIR/$hook $HOOK_DIR/$hook.local - fi - # create the symlink, overwriting the file if it exists - # probably the only way this would happen is if you're using an old version of git - # -- back when the sample hooks were not executable, instead of being named ____.sample - echo -n " Creating symlink..." - ln -s -f $INSTALL_DIR/$hook $HOOK_DIR - echo "${COLOR_GREEN} Done! ✓${COLOR_RESET}" -done \ No newline at end of file diff --git a/package.json b/package.json index 938cb21..48c4a5f 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "test-render": "mocha --reporter spec test/render-test", "pre-test-browser": "node test/create-browser-suite.js", "test-browser": "npm run pre-test-browser && zuul -- test/context-test.js test/parse-test.js test/scanner-test.js test/render-test-browser.js", - "test-browser-local": "npm run pre-test-browser && zuul --local 8080 -- test/context-test.js test/scanner-test.js test/parse-test.js test/render-test-browser.js" + "test-browser-local": "npm run pre-test-browser && zuul --local 8080 -- test/context-test.js test/scanner-test.js test/parse-test.js test/render-test-browser.js", + "postversion": "scripts/bump-version-in-source" }, "devDependencies": { "chai": "^3.4.0", diff --git a/hooks/pre-commit b/scripts/bump-version-in-source similarity index 78% rename from hooks/pre-commit rename to scripts/bump-version-in-source index db8ad45..2574d20 100755 --- a/hooks/pre-commit +++ b/scripts/bump-version-in-source @@ -33,19 +33,9 @@ class Bumper # if bumped, do extra stuff and notify the user if @bumped + `git add mustache.js` + `git commit --amend --no-edit` - # keep .mjs & .js|.min.js in sync - puts "> building and minifying `mustache.mjs`..." - `npm run build` - - # stage files for commit - `git add package.json` - @sources.each {|source| `git add #{source.path}`} - `git add mustache.min.js` - `git commit -m ":ship: bump to version #{@target_v}"` - - # notify codemonkey - puts "staged bumped files and created commit" puts_c 32, "successfully bumped version to #{@target_v}!" puts_c 33, "don't forget to `npm publish`!" end