mirror of
https://github.com/dorny/paths-filter.git
synced 2025-01-04 00:08:16 +00:00
27 lines
712 B
TypeScript
27 lines
712 B
TypeScript
|
import {exec} from '@actions/exec'
|
||
|
|
||
|
export async function fetchBranch(base: string): Promise<void> {
|
||
|
const exitCode = await exec('git', ['fetch', '--depth=1', 'origin', base])
|
||
|
if (exitCode !== 0) {
|
||
|
throw new Error(`Fetching branch ${base} failed, exiting`)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export async function getChangedFiles(base: string): Promise<string[]> {
|
||
|
let output = ''
|
||
|
const exitCode = await exec('git', ['diff-index', '--name-only', base], {
|
||
|
listeners: {
|
||
|
stdout: (data: Buffer) => (output += data.toString())
|
||
|
}
|
||
|
})
|
||
|
|
||
|
if (exitCode !== 0) {
|
||
|
throw new Error(`Couldn't determine changed files, exiting`)
|
||
|
}
|
||
|
|
||
|
return output
|
||
|
.split('\n')
|
||
|
.map(s => s.trim())
|
||
|
.filter(s => s.length > 0)
|
||
|
}
|