Skip to content

Instantly share code, notes, and snippets.

@mmieluch
Created March 6, 2019 09:28
Show Gist options
  • Save mmieluch/27dd081f7d12f4d5e97e9105c82a80a0 to your computer and use it in GitHub Desktop.
Save mmieluch/27dd081f7d12f4d5e97e9105c82a80a0 to your computer and use it in GitHub Desktop.
Add a `git hush` command. Takes filenames as arguments, but will not do any file stats check, instead will just redirect the filenames to `git update-index --assume-unchanged` command
#!/usr/bin/env node
const util = require('util')
const exec = util.promisify(require('child_process').exec)
const args = process.argv.slice(2)
if (!args.length) {
console.log('No filenames provided. Aborting!')
process.exitCode = 9
return
}
function _write (...arguments) {
for (let item of arguments) {
if (typeof item === 'string' && item.trim().length) {
console.log(item)
}
}
}
async function unhush () {
const cmdArg = args.join(' ')
const cmd = `git update-index --assume-unchanged ${cmdArg}`
try {
const { stdout, stderr } = await exec(cmd)
if (stderr) {
_write(err.message)
process.exitCode = 1
}
} catch (err) {
_write(err.message)
process.exitCode = 1
}
}
unhush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment