gitconfig
Version:
Run git config command
39 lines (34 loc) • 1.02 kB
JavaScript
/**
* Unset git config values.
* @function unset
* @param {string} key - Keys to unset.
* @param {object} [options] - Optional settings.
* @returns {Promise}
*/
const argx = require('argx')
const co = require('co')
const arrayreduce = require('arrayreduce')
const execcli = require('execcli')
/** @lends unset */
function unset (keys, options = {}) {
let args = argx(arguments)
if (args.pop('function')) {
throw new Error('Callback is no more supported. Use promise interface instead.')
}
keys = [].concat(args.shift('string|array') || [])
options = args.pop('object') || {}
keys = keys.concat(args.remain()).reduce(arrayreduce.arrayConcat(), [])
return co(function * () {
for (let key of keys) {
let cmdArgs = [ 'config' ]
cmdArgs.push('--unset')
if (options.location) {
cmdArgs.push('--' + options.location)
}
cmdArgs.push(key)
yield execcli('git', cmdArgs)
}
})
}
module.exports = unset