diff --git a/bin/postinstall.sh b/bin/postinstall.sh deleted file mode 100755 index 72db42e15a..0000000000 --- a/bin/postinstall.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if [ -d ".git/hooks" ]; then - if [ ! -f ".git/hooks/commit-msg" ]; then - echo "Installing pre-commit hook" - cd .git/hooks/ && cp ../../node_modules/angular-precommit/index.js commit-msg && cd ../../ - fi -fi \ No newline at end of file diff --git a/build/utils/postinstall.js b/build/utils/postinstall.js new file mode 100644 index 0000000000..6beaea9bb5 --- /dev/null +++ b/build/utils/postinstall.js @@ -0,0 +1,15 @@ +var fs = require('fs') + +if (fs.existsSync(".git/hooks")) { + let commitMsg = '.git/hooks/commit-msg' + if (!fs.existsSync(commitMsg)) { + let angularPrecommit = "./node_modules/angular-precommit/index.js" + if (fs.existsSync(angularPrecommit)) { + var fsExtra = require('fs-extra') + fsExtra.copy(angularPrecommit, commitMsg, (err) => { + if (err) throw err + console.log("Installing git pre-commit hook") + }) + } + } +} \ No newline at end of file diff --git a/package.json b/package.json index 1258744367..ccd6306b9a 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "test-fast": "grunt test-fast", "version": "node build/sri-update", "prepublishOnly": "grunt build && node build/sri-update --validate", - "postinstall": "./bin/postinstall.sh", + "postinstall": "node build/utils/postinstall.js", "release": "standard-version" }, "devDependencies": { @@ -65,6 +65,7 @@ "chai": "~3.5.0", "clone": "~1.0.2", "dot": "~1.0.3", + "fs-extra": "^4.0.1", "grunt": "^1.0.1", "grunt-babel": "^6.0.0", "grunt-contrib-clean": "^1.0.0",