1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

fix(cli): add --base option to run test command

This commit is contained in:
Divlo
2021-06-30 15:23:58 +02:00
parent ede3e7526b
commit 996dcd89c3
3 changed files with 25 additions and 8 deletions

View File

@ -9,13 +9,16 @@ const solutionsRegex = new RegExp(
export interface GitAffectedOptions {
isContinuousIntegration: boolean
base?: string
}
export class GitAffected implements GitAffectedOptions {
public isContinuousIntegration: boolean
public base?: string
constructor (options: GitAffectedOptions) {
this.isContinuousIntegration = options.isContinuousIntegration
this.base = options.base
}
public parseGitOutput (output: string): string[] {
@ -57,12 +60,14 @@ export class GitAffected implements GitAffectedOptions {
}
public async getAffectedSolutions (): Promise<Solution[]> {
const files = Array.from(
new Set([
...(await this.getUnpushedFiles()),
...(await this.getUncommittedFiles())
])
)
let files = [
...(await this.getUnpushedFiles()),
...(await this.getUncommittedFiles())
]
if (this.base != null) {
files.push(...(await this.getFilesUsingBaseAndHead(this.base, '.')))
}
files = Array.from(new Set(files))
const affectedSolutionsPaths = files.filter((filePath) => {
return solutionsRegex.test(filePath)
})