You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
684 B
31 lines
684 B
3 years ago
|
'use strict'
|
||
|
|
||
|
const fs = require('fs')
|
||
|
const hooks = require('./hooks.json')
|
||
|
const findParent = require('./utils/find-parent')
|
||
|
const findHooksDir = require('./utils/find-hooks-dir')
|
||
|
const is = require('./utils/is')
|
||
|
|
||
|
function removeHook(dir, name) {
|
||
|
const filename = `${dir}/${name}`
|
||
|
|
||
|
if (fs.existsSync(filename) && is.huskyOrYorkie(filename)) {
|
||
|
fs.unlinkSync(`${dir}/${name}`)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function uninstallFrom(huskyDir) {
|
||
|
try {
|
||
|
const hooksDir = findHooksDir(findParent(huskyDir, '.git'))
|
||
|
|
||
|
hooks.forEach(function(hookName) {
|
||
|
removeHook(hooksDir, hookName)
|
||
|
})
|
||
|
console.log('done\n')
|
||
|
} catch (e) {
|
||
|
console.error(e)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = uninstallFrom
|