diff --git a/.husky/.gitignore b/.husky/.gitignore index c9cdc63b070..31354ec1389 100644 --- a/.husky/.gitignore +++ b/.husky/.gitignore @@ -1 +1 @@ -_ \ No newline at end of file +_ diff --git a/package.json b/package.json index e9b99cdf4a1..ee557603fbe 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "eslint-plugin-prettier": "^3.1.4", "file-loader": "^6.0.0", "fork-ts-checker-webpack-plugin": "^6.0.5", - "husky": "^5.0.9", + "husky": "^5.1.2", "is-ci": "^2.0.0", "istanbul": "^0.4.5", "jest": "^26.6.3", @@ -154,6 +154,7 @@ "special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/generate-types --no-template-literals", "special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/generate-types --no-template-literals --write", "fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix", + "prepare": "husky install", "pretty-lint-base": "prettier \"*.{ts,json,yml,yaml,md}\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.json\" \"examples/*.md\"", "pretty-lint-base-all": "yarn pretty-lint-base \"*.js\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/helpers/*.js\" \"test/{configCases,watchCases,statsCases,hotCases,benchmarkCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"", "pretty-lint-fix": "yarn pretty-lint-base-all --loglevel warn --write", diff --git a/setup/setup.js b/setup/setup.js index ed5addb63c2..d1b4de9da6d 100644 --- a/setup/setup.js +++ b/setup/setup.js @@ -4,19 +4,10 @@ const fs = require("fs"); const path = require("path"); const root = process.cwd(); const node_modulesFolder = path.resolve(root, "node_modules"); -const huskyFolder = path.resolve(root, ".husky", "_"); const webpackDependencyFolder = path.resolve(root, "node_modules/webpack"); function setup() { return Promise.all([ - checkGitHooksInstalledAsync().then(async hasGitHooks => { - if (!hasGitHooks) { - await runSetupGitHooksAsync(); - if (!(await checkGitHooksInstalledAsync())) { - throw new Error("Git hooks were not successfully installed"); - } - } - }), checkSymlinkExistsAsync().then(async hasSymlink => { if (!hasSymlink) { await ensureYarnInstalledAsync(); @@ -42,10 +33,6 @@ async function runSetupSymlinkAsync() { await exec("yarn", ["link", "webpack"], "Link webpack into itself"); } -async function runSetupGitHooksAsync() { - await exec("yarn", ["run", "husky", "install"], "Enable Git hooks"); -} - function checkSymlinkExistsAsync() { return new Promise((resolve, reject) => { if ( @@ -60,16 +47,6 @@ function checkSymlinkExistsAsync() { }); } -function checkGitHooksInstalledAsync() { - return new Promise((resolve, reject) => { - if (fs.existsSync(huskyFolder)) { - resolve(true); - } else { - resolve(false); - } - }); -} - async function ensureYarnInstalledAsync() { const semverPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?$/; let hasYarn = false; diff --git a/yarn.lock b/yarn.lock index ada0eb4d317..80d99211d77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3250,10 +3250,10 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -husky@^5.0.9: - version "5.0.9" - resolved "https://registry.yarnpkg.com/husky/-/husky-5.0.9.tgz#6d38706643d66ed395bcd4ee952d02e3f15eb3a3" - integrity sha512-0SjcaY21a+IRdx7p7r/X33Vc09UR2m8SbP8yfkhUX2/jAmwcz+GR7i9jXkp2pP3GfX23JhMkVP6SWwXB18uXtg== +husky@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/husky/-/husky-5.1.2.tgz#dc6a1f68640455d8d98c28875e073087f86c5081" + integrity sha512-lilaRYeDXcAOj8DuRnN9IxUyEMVbYg9rK7yVNkPB5V4hCvxIUxpMeiv9K2h77CE0HzjCnk1Br0oWe1IghXngDQ== iconv-lite@0.4.24, iconv-lite@^0.4.4: version "0.4.24"