浏览代码

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 <patch | minor | major>` 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.
tags/v4.2.0
Phillip Johnsen 5 年前
父节点
当前提交
a93c39eef2
共有 3 个文件被更改,包括 4 次插入35 次删除
  1. +0
    -22
      hooks/install-hooks.sh
  2. +2
    -1
      package.json
  3. +2
    -12
      scripts/bump-version-in-source

+ 0
- 22
hooks/install-hooks.sh 查看文件

@@ -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

+ 2
- 1
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",


hooks/pre-commit → 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

正在加载...
取消
保存