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 0.15.0-beta.4 to 0.15.0-beta.5

template/hook.sh

16

husky.js
const fs = require('fs')
const path = require('path')
const execa = require('execa')

@@ -6,8 +7,8 @@

if (fs.existsSync('./lib/install/index.js')) {
// Can be "install" or "uninstall"
// Action can be "install" or "uninstall"
const action = process.argv[2]
// Find Git dir
const { status, stdout, stderr } = execa.sync('git', ['rev-parse --git-dir'])
const gitDir = stdout
const { status, stdout, stderr } = execa.sync('git', ['rev-parse', '--absolute-git-dir'])
const gitDir = path.resolve(stdout) // Needed to normalize path on Windows

@@ -19,6 +20,11 @@ if (status !== 0) {

// Husky dir
const huskyDir = process.env.HUSKY_ENV === 'dev'
? path.join(__dirname, 'node_modules/husky')
: __dirname
// Run installer
require('./lib/install')[action](__dirname, gitDir)
require('./lib/install')[action](gitDir, huskyDir)
} else {
console.error("Error can't find lib directory, run `npm run build`")
}
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
// Used to identify scripts created by Husky
exports.huskyIdentifier = '# husky';
exports.default = `#!/bin/sh
${exports.huskyIdentifier}
./node_modules/husky/scripts/run.sh
`;
exports.default = fs
.readFileSync(path.join(__dirname, '../../template/hook.sh'), 'utf-8')
.replace('__huskyIdentifier__', exports.huskyIdentifier);

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

const pkgDir = require("pkg-dir");
const read_pkg_1 = require("read-pkg");
const readPkg = require("read-pkg");
const hookScript_1 = require("./hookScript");

@@ -79,8 +79,8 @@ const is_1 = require("./is");

}
function getHooks(userDir) {
const gitHooksDir = path.join(userDir, '.git/hooks');
function getHooks(gitDir) {
const gitHooksDir = path.join(gitDir, 'hooks');
return hookList.map(hookName => path.join(gitHooksDir, hookName));
}
function getConf(huskyDir) {
const pkg = read_pkg_1.default.sync(huskyDir);
const pkg = readPkg.sync(huskyDir);
const defaults = {

@@ -103,4 +103,6 @@ skipCI: true

}
if (userDir !== gitDir) {
if (path.join(userDir, '.git') !== gitDir) {
console.log(`Expecting package.json to be at the same level than .git, skipping Git hooks installation`);
console.log(`gitDir: ${gitDir}`);
console.log(`userDir: ${userDir}`);
return;

@@ -117,3 +119,3 @@ }

const userDir = pkgDir.sync(path.join(huskyDir, '..'));
if (userDir === gitDir) {
if (path.join(userDir, '.git') === gitDir) {
// Remove hooks

@@ -120,0 +122,0 @@ const hooks = getHooks(gitDir);

{
"name": "husky",
"version": "0.15.0-beta.4",
"version": "0.15.0-beta.5",
"description": "Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)",

@@ -9,4 +9,4 @@ "scripts": {

"preuninstall": "node husky uninstall",
"devInstall": "npm run build && node husky-dev install",
"devUninstall": "npm run build && node husky-dev uninstall",
"devInstall": "npm run build && cross-env HUSKY_ENV=dev node husky install && node husky-dev",
"devUninstall": "npm run build && node husky uninstall",
"build": "del-cli lib && tsc",

@@ -51,11 +51,12 @@ "prepublishOnly": "npm run test && npm run build && pkg-ok",

"@types/execa": "^0.7.0",
"@types/jest": "^20",
"@types/node": "^8.0.31",
"@types/jest": "^21.1.2",
"@types/node": "^8.0.32",
"cross-env": "^5.0.5",
"del": "^3.0.0",
"del-cli": "^1.1.0",
"jest": "^20",
"jest": "^21.2.1",
"pkg-ok": "^1.1.0",
"prettier": "^1.7.2",
"prettier": "^1.7.4",
"tempy": "^0.2.1",
"ts-jest": "^21.0.1",
"ts-jest": "^21.1.0",
"tslint": "^5.7.0",

@@ -62,0 +63,0 @@ "tslint-config-prettier": "^1.5.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