Comparing version 0.5.2 to 0.5.3
// Run when package is installed | ||
var fs = require('fs') | ||
var fs = require('fs') | ||
var husky = require('../src/') | ||
var dir = __dirname + '/../../../.git/hooks' | ||
console.log('\033[36m%s\033[0m', 'husky') | ||
console.log(' setting up hooks in .git/hooks/') | ||
if (fs.existsSync(dir)) { | ||
husky.create(dir, 'pre-commit', 'npm run precommit --silent') | ||
husky.create(dir, 'pre-push', 'npm run prepush --silent') | ||
console.log(' done\n') | ||
} else { | ||
console.log(' can\'t find .git/hooks/\n') | ||
} | ||
husky.hooksDir(function(err, dir) { | ||
if (err) { | ||
console.error(' ' + err) | ||
} else { | ||
husky.create(dir, 'pre-commit', 'npm run precommit --silent') | ||
husky.create(dir, 'pre-push', 'npm run prepush --silent') | ||
console.log(' done\n') | ||
} | ||
}) |
// Run when package is uninstalled | ||
var husky = require('../src/') | ||
var dir = __dirname + '/../../../.git/hooks' | ||
console.log('\033[36m%s\033[0m', 'husky') | ||
console.log(' uninstalling') | ||
husky.remove(dir, 'pre-commit') | ||
husky.remove(dir, 'pre-push') | ||
husky.hooksDir(function(err, dir) { | ||
if (!err) { | ||
husky.remove(dir, 'pre-commit') | ||
husky.remove(dir, 'pre-push') | ||
console.log(' done\n') | ||
console.log(' done\n') | ||
} | ||
}) |
{ | ||
"name": "husky", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Prevents bad commit or push (git hooks, pre-commit, pre-push and all that stuff...)", | ||
@@ -32,4 +32,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"rm-r": "^1.0.2" | ||
"rimraf": "^2.2.8" | ||
} | ||
} |
@@ -1,2 +0,3 @@ | ||
var fs = require('fs') | ||
var fs = require('fs') | ||
var exec = require('child_process').exec | ||
@@ -9,2 +10,12 @@ module.exports = { | ||
hooksDir: function(callback) { | ||
exec('git rev-parse --show-toplevel', function(error, stdout, stderr) { | ||
if (error) { | ||
callback(stderr, null) | ||
} else { | ||
callback(null, stdout.trim() + '/.git/hooks') | ||
} | ||
}) | ||
}, | ||
write: function(filename, data) { | ||
@@ -21,4 +32,4 @@ fs.writeFileSync(filename, data) | ||
// Needed on OS X when nvm is used and committing from Sublime Text | ||
if (process.platform === 'darwin') { | ||
// Needed on OS X / Linux when nvm is used and committing from Sublime Text | ||
if (process.platform !== 'win32') { | ||
data += 'PATH="' + process.env.PATH + '"\n' | ||
@@ -25,0 +36,0 @@ } |
var assert = require('assert') | ||
var fs = require('fs') | ||
var rm = require('rm-r') | ||
var husky = require('../src/') | ||
var fs = require('fs') | ||
var path = require('path') | ||
var rm = require('rimraf') | ||
var husky = require('../src/') | ||
// Some very basic tests... | ||
husky.hooksDir(function(err, dir) { | ||
assert.equal(err, null) | ||
assert.equal(dir, path.resolve(__dirname + '/../.git/hooks')) | ||
}) | ||
// Create tmp dir | ||
var dir = __dirname + '/../tmp' | ||
rm(dir) | ||
fs.mkdir(dir, function() {}) | ||
rm.sync(dir) | ||
fs.mkdirSync(dir) | ||
@@ -35,2 +41,2 @@ // husky should be able to create a hook and update it | ||
assert.equal(fs.readFileSync(dir + '/user-pre-commit', 'utf-8'), '') | ||
assert.equal(fs.readFileSync(dir + '/user-pre-commit', 'utf-8'), '') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5908
108
1