commitplease
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -31,25 +31,18 @@ // based on install.js by bahmutov | ||
var name = "commit-msg"; | ||
var hook = path.resolve(hooks, "commit-msg"); | ||
var symlink = path.relative(path.resolve(hooks), "./commit-msg-hook.js"); | ||
console.log('installing hook', name); | ||
var hook = path.resolve(hooks, name); | ||
var hookContent = fs.readFileSync( "./commit-msg-hook.js" ); | ||
// If there's an existing `pre-commit` hook we want to back it up instead of | ||
// overriding it and losing it completely | ||
if (fs.existsSync(hook)) { | ||
// Check for existing hook | ||
if ( fs.existsSync( hook ) ) { | ||
var stats = fs.lstat( hook ); | ||
if ( stats.isSymbolicLink() && fs.readlinkSync( hook ) === symlink ) { | ||
console.log( "Found the correct existing symlink, doing nothing" ); | ||
process.exit(0); | ||
} | ||
console.log('Detected an existing git commit-msg hook'); | ||
console.log(''); | ||
console.log(name + ': Detected an existing git hook'); | ||
fs.writeFileSync(hook + '.old', fs.readFileSync(hook)); | ||
fs.unlinkSync(hook); | ||
console.log(name + ': Old hook backuped to .old'); | ||
console.log(''); | ||
console.log('Remove it and install this package again to install the symlink'); | ||
process.exit(0); | ||
} | ||
// Everything is ready for the installation of the pre-commit hook. Write it and | ||
// make it executable. | ||
console.log(path.relative(path.resolve(hooks), "./commit-msg-hook.js")); | ||
fs.symlinkSync(path.relative(path.resolve(hooks), "./commit-msg-hook.js"), hook); | ||
// fs.writeFileSync(hook, hookContent); | ||
// fs.chmodSync(hook, '755'); | ||
fs.symlinkSync(symlink, hook); |
{ | ||
"name": "commitplease", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Validates strings as commit messages", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
6452
155