From e18fd626677d7f7d081fa1e973a4469f1757ffc2 Mon Sep 17 00:00:00 2001 From: David Verbenyi Date: Fri, 19 May 2023 12:47:03 +0100 Subject: [PATCH 1/5] MYSTATS-5213-Add NVM to the pre-commit hook --- hook | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hook b/hook index 1bf23b8..08d56b2 100755 --- a/hook +++ b/hook @@ -18,6 +18,12 @@ if [[ -z "$HAS_NODE" ]]; then source_home_file ".bash_profile" || source_home_file ".zshrc" || source_home_file ".bashrc" || true fi +[ "$NVM_DIR" = "" ] && export NVM_DIR="$HOME/.nvm" +if [ -f "$NVM_DIR/nvm.sh" ]; then + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +fi + NODE=`which node 2> /dev/null` NODEJS=`which nodejs 2> /dev/null` IOJS=`which iojs 2> /dev/null` @@ -37,8 +43,12 @@ elif [[ -x "$LOCAL" ]]; then BINARY="$LOCAL" fi +if [ ! -f "$BINARY" ]; then + echo "something wrong: node not exist" + exit 1 +fi # -# Add --dry-run cli flag support so we can execute this hook without side effects +# Add --dry-run cli flag support so we can execute this hook without side affects # and see if it works in the current environment # if [[ $* == *--dry-run* ]]; then @@ -47,4 +57,4 @@ if [[ $* == *--dry-run* ]]; then fi else "$BINARY" "$("$BINARY" -e "console.log(require.resolve('pre-commit'))")" -fi +fi \ No newline at end of file From c1c043908bc649b9d3bd85ef97db688fad1c700c Mon Sep 17 00:00:00 2001 From: David Verbenyi Date: Fri, 19 May 2023 12:48:16 +0100 Subject: [PATCH 2/5] MYSTATS-5213 Update repo link from package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index dc1ff70..1ebbcb0 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "repository": { "type": "git", - "url": "git://github.com/observing/pre-commit.git" + "url": "git://github.com/bbc/pre-commit.git" }, "keywords": [ "git", @@ -27,7 +27,7 @@ "development" ], "author": "Arnout Kazemier ", - "homepage": "https://github.com/observing/pre-commit", + "homepage": "https://github.com/bbc/pre-commit", "license": "MIT", "dependencies": { "cross-spawn": "^5.0.1", @@ -38,6 +38,6 @@ "assume": "~1.5.0", "istanbul": "0.4.x", "mocha": "~3.3.0", - "pre-commit": "git://github.com/observing/pre-commit.git" + "pre-commit": "git://github.com/bbc/pre-commit.git" } } From 2eb922fcc5670ee6c323f889a3c9638a3b0eec84 Mon Sep 17 00:00:00 2001 From: David Verbenyi Date: Fri, 19 May 2023 14:18:05 +0100 Subject: [PATCH 3/5] MYSTATS-5213-Update pre-commit hook to use nvm Updated the pre-commit hook to try using the NVM node first rather than the default node. --- hook | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hook b/hook index 08d56b2..a28fcf2 100755 --- a/hook +++ b/hook @@ -22,8 +22,10 @@ fi if [ -f "$NVM_DIR/nvm.sh" ]; then [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + nvm use fi +NVMNODE=`nvm which node 2> /dev/null` NODE=`which node 2> /dev/null` NODEJS=`which nodejs 2> /dev/null` IOJS=`which iojs 2> /dev/null` @@ -33,7 +35,9 @@ BINARY= # # Figure out which binary we need to use for our script execution. # -if [[ -n "$NODE" ]]; then +if [[ -n "$NVMNODE" ]]; then + BINARY="$NVMNODE" +elif [[ -n "$NODE" ]]; then BINARY="$NODE" elif [[ -n "$NODEJS" ]]; then BINARY="$NODEJS" From 66db2332e6db213878cce7660c109704c26571fa Mon Sep 17 00:00:00 2001 From: David Verbenyi Date: Mon, 22 May 2023 08:59:21 +0100 Subject: [PATCH 4/5] MYSTATS-5213-Add nvm install to pre-commit hook --- hook | 1 + 1 file changed, 1 insertion(+) diff --git a/hook b/hook index a28fcf2..2470287 100755 --- a/hook +++ b/hook @@ -22,6 +22,7 @@ fi if [ -f "$NVM_DIR/nvm.sh" ]; then [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + nvm install nvm use fi From 0ed57c4aaf8a9c1bddd0178889ce5d724f932904 Mon Sep 17 00:00:00 2001 From: David Verbenyi Date: Wed, 9 Aug 2023 15:36:53 +0100 Subject: [PATCH 5/5] MYSTATS-5213-Update installation instructions Updated the readme with installation instructions from GitHub. --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 16f6b2e..31bd661 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,10 @@ It's advised to install the **pre-commit** module as a `devDependencies` in your `package.json` as you only need this for development purposes. To install the module simply run: -``` -npm install --save-dev pre-commit +```bash +npm install --save-dev github:bbc/pre-commit +# or +npm install --save-dev https://github.com/bbc/pre-commit ``` To install it as `devDependency`. When this module is installed it will override