From a0599abe00d98d701ab415c8febe16733a25e7c4 Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Wed, 24 Mar 2021 09:37:10 +0000 Subject: [PATCH] fix(workspace): Update husky configuration for husky5. --- .husky/.gitignore | 1 + .husky/commit-msg | 4 ++++ .husky/pre-commit | 4 ++++ package.json | 11 ++++------- postinstall.js | 3 +++ 5 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 .husky/.gitignore create mode 100755 .husky/commit-msg create mode 100755 .husky/pre-commit diff --git a/.husky/.gitignore b/.husky/.gitignore new file mode 100644 index 0000000000..31354ec138 --- /dev/null +++ b/.husky/.gitignore @@ -0,0 +1 @@ +_ diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000000..2b9eafee8e --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/bash +. "$(dirname "$0")/_/husky.sh" + +npm run commit-msg diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000000..8872b68ea2 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/bash +. "$(dirname "$0")/_/husky.sh" + +npm run pre-commit diff --git a/package.json b/package.json index 88fd830e3a..2996168cb5 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,10 @@ "bazel": "bazelisk", "bazel:test": "bazelisk query \"attr(generator_function, jest, //...)\" | xargs bazelisk test", "bazel:stylelint": "node tools/scripts/stylelint.js", - "workspace-generator": "nx workspace-generator" + "workspace-generator": "nx workspace-generator", + "prepare-husky": "husky install", + "pre-commit": "nx format:write && git update-index --again", + "commit-msg": "npx commitlint --edit" }, "author": "Dynatrace", "license": "SEE LICENSE IN LICENSE", @@ -56,12 +59,6 @@ "engines": { "node": ">=12.10" }, - "husky": { - "hooks": { - "pre-commit": "nx format:write && git update-index --again", - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" - } - }, "dependencies": { "@angular/animations": "^11.2.4", "@angular/cdk": "^11.0.3", diff --git a/postinstall.js b/postinstall.js index d71b58c556..391831df24 100644 --- a/postinstall.js +++ b/postinstall.js @@ -14,6 +14,9 @@ const NGCC_BINARY = resolve( const NGC_BINARY = resolve('./node_modules/@angular/compiler-cli/src/main.js'); async function main() { + // Apply the husky configuration + await execCommand(`npm run prepare-husky`); + // Applying all the patches to the packages await execCommand(`node ${require.resolve('patch-package')}`); // when running with bazel we need to perform a ngcc to compile