| 6 | // So we rely on environment variables instead. |
| 7 | |
| 8 | export function getDiffFiles() { |
| 9 | // Instead of testing every single file possible, if there's |
| 10 | // an environment variable called `DIFF_FILES` or one called |
| 11 | // `DIFF_FILE` then use that. |
| 12 | // If `DIFF_FILES` is set, it's expected to be a space separated |
| 13 | // string. If `DIFF_FILE` is set, it's expected to be a text file |
| 14 | // which contains a space separated string. |
| 15 | const diffFiles = [] |
| 16 | // Setting an environment varible called `DIFF_FILES` is optional. |
| 17 | // But if and only if it's set, we will respect it. |
| 18 | // And if it set, turn it into a cleaned up Set so it's made available |
| 19 | // every time we use it. |
| 20 | // Alternatively, you can put all the files change changed into a |
| 21 | // text file and do `export DIFF_FILE=files-that-changed.txt` |
| 22 | if (process.env.DIFF_FILES) { |
| 23 | diffFiles.push(...process.env.DIFF_FILES.trim().split(/\s+/g)) |
| 24 | } else if (process.env.DIFF_FILE) { |
| 25 | diffFiles.push(...fs.readFileSync(process.env.DIFF_FILE, 'utf-8').trim().split(/\s+/g)) |
| 26 | } |
| 27 | |
| 28 | return diffFiles |
| 29 | } |