Repository URL to install this package:
|
Version:
3.0.0-beta.2 ▾
|
import { exec } from 'child_process'
import { promisify } from 'util'
const asyncExec = promisify(exec)
/**
* @example getChangedFiles().then(changed => changed.forEach(file => console.log(file)))
*/
export async function getChangedFiles(): Promise<string[]> {
return new Promise(resolve => {
asyncExec('git diff --name-only `git merge-base origin/master HEAD`')
.then(result => {
const output = result.stdout!.toString()
const files = output.split('\n').filter(line => line !== '')
const filesChangedList = files.filter(
file => file.endsWith('.ts') || file.endsWith('.tsx')
)
resolve(filesChangedList)
})
.catch(exception => {
console.error(exception)
resolve([])
})
}) as Promise<string[]>
}