UNPKG

git-command-helper

Version:
18 lines (15 loc) 552 B
// git-command-helper 2.1.0 by Dimas Lanjaka <dimaslanjaka@gmail.com> (https://www.webmanajemen.com) import * as spawn from 'cross-spawn'; /** * check file is untracked * @param filePath */ async function isUntracked(filePath, opt) { const defaults = { cwd: process.cwd() }; opt = Object.assign(defaults, opt || {}); const untrack = (await spawn.async("git", ["diff", "--no-index", "--numstat", "/dev/null", filePath], opt)).stdout.split(/\r?\n/).filter(str => str.length > 0); return untrack.length === 1; } export { isUntracked };