Skip to content

Commit

Permalink
Merge pull request #12799 from chenxsan/feature/update-husky
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Mar 1, 2021
2 parents 97a6269 + 857783b commit 9c63f11
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .husky/.gitignore
@@ -1 +1 @@
_
_
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
23 changes: 0 additions & 23 deletions setup/setup.js
Expand Up @@ -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();
Expand All @@ -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 (
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -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"
Expand Down

0 comments on commit 9c63f11

Please sign in to comment.