Skip to content

Commit

Permalink
feat(deps): bump husky from 6.0.0 to 7.0.0 (#992)
Browse files Browse the repository at this point in the history
Bumps [husky](https://github.com/typicode/husky) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/typicode/husky/releases)
- [Commits](typicode/husky@v6.0.0...v7.0.0)

---
updated-dependencies:
- dependency-name: husky
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and ybiquitous committed Jul 5, 2021
1 parent e80de1b commit 3076a00
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

18 changes: 16 additions & 2 deletions lib/init.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { promises as fsPromises } from "fs";
import { promises as fsPromises, existsSync } from "fs";
import { join, relative, resolve } from "path";
import { inspect } from "util";
import { defaultLogger } from "./logger.js";

const { copyFile, mkdir, readFile, writeFile } = fsPromises;
const { copyFile, mkdir, readFile, writeFile, unlink } = fsPromises;

/**
* @param {unknown} value
Expand Down Expand Up @@ -124,6 +124,18 @@ const initCommand = (baseDir, logger) => {
async writePackageFile(name, ...names) {
await copy(packagePath(name, ...names), currentPath(name, ...names));
},

// NOTE: husky v7 no longer requires `.husky/.gitignore`.
// See https://github.com/typicode/husky/releases/tag/v7.0.0
//
// TODO: `fsPromises.rm()` is available since Node 14.14.0.
// See https://nodejs.org/api/fs.html#fs_fspromises_rm_path_options
async removeNeedlessHuskyIgnore() {
const huskyGitignore = currentPath(".husky", ".gitignore");
if (existsSync(huskyGitignore)) {
await unlink(huskyGitignore);
}
},
};
};

Expand All @@ -142,6 +154,8 @@ export async function init({ cwd = process.cwd(), logger = defaultLogger } = {})
await cmd.writePackageFile(".husky", "commit-msg");
await cmd.writePackageFile(".husky", "post-commit");
await cmd.writePackageFile(".husky", "pre-commit");

await cmd.removeNeedlessHuskyIgnore();
}

export const command = "init";
Expand Down
17 changes: 10 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"eslint": "^7.26.0",
"husky": "^6.0.0",
"husky": "^7.0.0",
"lint-staged": "^11.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.0",
Expand Down
14 changes: 13 additions & 1 deletion test/init.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { copyFileSync, mkdirSync, readFileSync, rmdirSync } from "fs";
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmdirSync, writeFileSync } from "fs";
import { tmpdir } from "os";
import { join, resolve } from "path";
import { init } from "../lib/init.js";
Expand Down Expand Up @@ -26,6 +26,7 @@ const sandbox = async (callback) => {

return await callback({
fixture,
workDir,
readWorkFile: (name) => readFileSync(join(workDir, name), "utf8"),
logMessage: () => logMsgs.join(""),
initArgs: { cwd: workDir, logger },
Expand Down Expand Up @@ -99,3 +100,14 @@ test("End-to-End via CLI", () =>
`);
expect(stderr).toEqual("");
}));

test("Remove `.husky/.gitignore` if exists", () =>
sandbox(async (ctx) => {
mkdirSync(join(ctx.workDir, ".husky"));
writeFileSync(join(ctx.workDir, ".husky", ".gitignore"), "_");
writeFileSync(join(ctx.workDir, "package.json"), "{}");

await init(ctx.initArgs);

expect(existsSync(join(ctx.workDir, ".husky", ".gitignore"))).toEqual(false);
}));

0 comments on commit 3076a00

Please sign in to comment.