Socket
Socket
Sign inDemoInstall

husky

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

husky - npm Package Compare versions

Comparing version 6.0.0 to 7.0.0

husky.sh

51

lib/bin.js
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const _1 = require("./");
function readPkg() {
return JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf-8'));
}
const pkg = readPkg();
const [, , cmd, ...args] = process.argv;
function version() {
console.log(pkg.version);
}
function help() {
console.log(`Usage
const p = require("path");
const h = require("./");
function help(code) {
console.log(`Usage:
husky install [dir] (default: .husky)
husky uninstall
husky set|add <file> [cmd]`);
process.exit(code);
}
function misuse() {
help();
process.exit(2);
}
const [, , cmd, ...args] = process.argv;
const ln = args.length;
const [x, y] = args;
const hook = (fn) => () => !ln || ln > 2 ? help(2) : fn(x, y);
const cmds = {
install(dir) {
args.length > 1 ? misuse() : _1.install(dir);
},
uninstall: _1.uninstall,
set(...args) {
args.length === 0 || args.length > 2 ? misuse() : _1.set(args[0], args[1]);
},
add(...args) {
args.length === 0 || args.length > 2 ? misuse() : _1.add(args[0], args[1]);
},
'--version': version,
'-v': version,
install: () => (ln > 1 ? help(2) : h.install(x)),
uninstall: h.uninstall,
set: hook(h.set),
add: hook(h.add),
['-v']: () => console.log(require(p.join(__dirname, '../package.json')).version),
};
cmds[cmd] ? cmds[cmd](...args) : help();
try {
cmds[cmd] ? cmds[cmd]() : help(0);
}
catch (e) {
console.error(e.message);
process.exit(1);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uninstall = exports.add = exports.set = exports.install = void 0;
const cp = require("child_process");
const fs = require("fs");
const cp = require("child_process");
const path = require("path");
function l(msg) {
console.log(`husky - ${msg}`);
}
const p = require("path");
const l = (msg) => console.log(`husky - ${msg}`);
const git = (args) => cp.spawnSync('git', args, { stdio: 'inherit' });
function install(dir = '.husky') {
if (cp.spawnSync('git', ['rev-parse']).status !== 0) {
l('not a Git repository, skipping hooks installation');
if (git(['rev-parse']).status) {
return;
}
const url = 'https://typicode.github.io/husky/#/?id=custom-directory';
if (!path.resolve(process.cwd(), dir).startsWith(process.cwd())) {
const url = 'https://git.io/Jc3F9';
if (!p.resolve(process.cwd(), dir).startsWith(process.cwd())) {
throw new Error(`.. not allowed (see ${url})`);

@@ -23,6 +21,6 @@ }

try {
fs.mkdirSync(path.join(dir, '_'), { recursive: true });
fs.writeFileSync(path.join(dir, '.gitignore'), '_\n');
fs.copyFileSync(path.join(__dirname, 'husky.sh'), path.join(dir, '_/husky.sh'));
const { error } = cp.spawnSync('git', ['config', 'core.hooksPath', dir]);
fs.mkdirSync(p.join(dir, '_'), { recursive: true });
fs.writeFileSync(p.join(dir, '_/.gitignore'), '*');
fs.copyFileSync(p.join(__dirname, '../husky.sh'), p.join(dir, '_/husky.sh'));
const { error } = git(['config', 'core.hooksPath', dir]);
if (error) {

@@ -40,3 +38,3 @@ throw error;

function set(file, cmd) {
const dir = path.dirname(file);
const dir = p.dirname(file);
if (!fs.existsSync(dir)) {

@@ -64,6 +62,4 @@ throw new Error(`can't create hook, ${dir} directory doesn't exist (try running husky install)`);

function uninstall() {
cp.spawnSync('git', ['config', '--unset', 'core.hooksPath'], {
stdio: 'inherit',
});
git(['config', '--unset', 'core.hooksPath']);
}
exports.uninstall = uninstall;
{
"name": "husky",
"version": "6.0.0",
"version": "7.0.0",
"description": "Modern native Git hooks made easy",
"bin": "lib/bin.js",
"main": "lib/index.js",
"files": [
"lib"
],
"keywords": [

@@ -15,8 +10,31 @@ "git",

],
"author": "Typicode <typicode@gmail.com>",
"license": "MIT",
"homepage": "https://typicode.github.io/husky",
"repository": "github:typicode/husky",
"repository": "typicode/husky",
"funding": "https://github.com/sponsors/typicode",
"gitHead": "cb4e3b913e2d8963af3179650ed550d3a0e210f5"
"license": "MIT",
"author": "Typicode <typicode@gmail.com>",
"bin": "lib/bin.js",
"main": "lib/index.js",
"files": [
"lib",
"husky.sh"
],
"scripts": {
"build": "tsc",
"test": "sh test/all.sh",
"serve": "docsify serve docs",
"prepare": "npm run build && node lib/bin install"
},
"devDependencies": {
"@commitlint/cli": "^12.0.1",
"@commitlint/config-conventional": "^12.0.1",
"@tsconfig/node12": "^1.0.7",
"@types/node": "^15.3.1",
"@typicode/eslint-config": "^0.1.2",
"docsify-cli": "^4.4.3",
"typescript": "^4.2.3"
},
"engines": {
"node": ">=12"
}
}
# husky
[![Open Collective](https://opencollective.com/husky/all/badge.svg?label=financial+contributors)](https://opencollective.com/husky)
> Modern native Git hooks made easy

@@ -9,2 +7,8 @@

# Install
```
npm install husky --save-dev
```
# Usage

@@ -15,3 +19,4 @@

```sh
npm set-script prepare "husky install" && npm run prepare
npm set-script prepare "husky install"
npm run prepare
```

@@ -29,2 +34,3 @@

$ git commit -m "Keep calm and commit"
# `npm test` will run
```

@@ -35,7 +41,1 @@

https://typicode.github.io/husky
__Important__ upgrading from v4 to v6 requires additional steps, please see the docs.
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc