Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 4.0.10 to 4.1.0

bin/run.js

2

lib/getConf.js

@@ -12,2 +12,2 @@ "use strict";

}
exports.default = getConf;
exports.getConf = getConf;

@@ -9,74 +9,6 @@ "use strict";

const debug_1 = require("../debug");
const getConf_1 = __importDefault(require("../getConf"));
const getScript_1 = __importDefault(require("./getScript"));
const is_1 = require("./is");
const hookList = [
'applypatch-msg',
'pre-applypatch',
'post-applypatch',
'pre-commit',
'pre-merge-commit',
'prepare-commit-msg',
'commit-msg',
'post-commit',
'pre-rebase',
'post-checkout',
'post-merge',
'pre-push',
'pre-receive',
'update',
'post-receive',
'post-update',
'push-to-checkout',
'pre-auto-gc',
'post-rewrite',
'sendemail-validate'
];
function writeHook(filename, script) {
fs_1.default.writeFileSync(filename, script, 'utf-8');
fs_1.default.chmodSync(filename, 0o0755);
}
function createHook(filename, script) {
// Get name, used for logging
const name = path_1.default.basename(filename);
// Check if hook exist
if (fs_1.default.existsSync(filename)) {
const hook = fs_1.default.readFileSync(filename, 'utf-8');
// Migrate
if (is_1.isGhooks(hook)) {
console.log(`migrating existing ghooks script: ${name}`);
return writeHook(filename, script);
}
// Migrate
if (is_1.isPreCommit(hook)) {
console.log(`migrating existing pre-commit script: ${name}`);
return writeHook(filename, script);
}
// Update
if (is_1.isHusky(hook) || is_1.isYorkie(hook)) {
return writeHook(filename, script);
}
// Skip
console.log(`skipping existing user hook: ${name}`);
return;
}
// Create hook if it doesn't exist
writeHook(filename, script);
}
function createHooks(filenames, script) {
filenames.forEach((filename) => createHook(filename, script));
}
function canRemove(filename) {
if (fs_1.default.existsSync(filename)) {
const data = fs_1.default.readFileSync(filename, 'utf-8');
return is_1.isHusky(data);
}
return false;
}
function removeHook(filename) {
fs_1.default.unlinkSync(filename);
}
function removeHooks(filenames) {
filenames.filter(canRemove).forEach(removeHook);
}
const getConf_1 = require("../getConf");
const hooks_1 = require("./hooks");
const localScript_1 = require("./localScript");
const mainScript_1 = require("./mainScript");
// This prevents the case where someone would want to debug a node_module that has

@@ -90,6 +22,2 @@ // husky as devDependency and run npm install from node_modules directory

}
function getHooks(gitDir) {
const gitHooksDir = getGitHooksDir(gitDir);
return hookList.map((hookName) => path_1.default.join(gitHooksDir, hookName));
}
function install({ absoluteGitCommonDir, relativeUserPkgDir, userPkgDir, pmName, // package manager name

@@ -99,3 +27,3 @@ isCI // running in CI or not

// Get conf from package.json or .huskyrc
const conf = getConf_1.default(userPkgDir);
const conf = getConf_1.getConf(userPkgDir);
// Checks

@@ -116,6 +44,5 @@ if (isCI && conf.skipCI) {

debug_1.debug(`Installing hooks in ${gitHooksDir}`);
const hooks = getHooks(absoluteGitCommonDir);
// Prefix can be an empty string
const script = getScript_1.default({ relativeUserPkgDir, pmName });
createHooks(hooks, script);
hooks_1.createHooks(gitHooksDir);
localScript_1.createLocalScript(gitHooksDir, pmName, relativeUserPkgDir);
mainScript_1.createMainScript(gitHooksDir);
}

@@ -129,5 +56,7 @@ exports.install = install;

// Remove hooks
const hooks = getHooks(absoluteGitCommonDir);
removeHooks(hooks);
const gitHooksDir = getGitHooksDir(absoluteGitCommonDir);
hooks_1.removeHooks(gitHooksDir);
localScript_1.removeLocalScript(gitHooksDir);
mainScript_1.removeMainScript(gitHooksDir);
}
exports.uninstall = uninstall;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getScript_1 = require("./getScript");
const hooks_1 = require("./hooks");
function isHusky(data) {

@@ -9,3 +9,3 @@ // Husky v0.14 and prior used #husky as an identifier.

const previousHuskyIdentifier = '#husky';
return (data.indexOf(getScript_1.huskyIdentifier) !== -1 ||
return (data.indexOf(hooks_1.huskyIdentifier) !== -1 ||
data.indexOf(previousHuskyIdentifier) !== -1);

@@ -12,0 +12,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

const child_process_1 = require("child_process");
const getConf_1 = __importDefault(require("../getConf"));
const getConf_1 = require("../getConf");
const read_pkg_1 = require("../read-pkg");

@@ -28,3 +28,3 @@ // Husky <1.0.0 (commands were defined in pkg.scripts)

function getCommand(cwd, hookName) {
const config = getConf_1.default(cwd);
const config = getConf_1.getConf(cwd);
return config && config.hooks && config.hooks[hookName];

@@ -31,0 +31,0 @@ }

{
"name": "husky",
"version": "4.0.10",
"version": "4.1.0",
"description": "Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)",
"bin": {
"husky-run": "./run.js",
"husky-run": "./bin/run.js",
"husky-upgrade": "./lib/upgrader/bin.js"

@@ -8,0 +8,0 @@ },

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