use prepare to run husky install
This commit is contained in:
parent
3ff304f950
commit
857783b4ee
|
@ -1 +1 @@
|
|||
_
|
||||
_
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue