| 30 | }); |
| 31 | |
| 32 | async function main() { |
| 33 | validate(); |
| 34 | |
| 35 | // Stash changes in working copy if needed |
| 36 | const pop = await stash(); |
| 37 | |
| 38 | // Make base and source available as dedicated remotes |
| 39 | await Promise.all([ |
| 40 | () => fetch({ name: "base", url: `https://github.com/${REPO_SLUG}.git` }), |
| 41 | IS_PR |
| 42 | ? () => fetch({ name: "source", url: `https://github.com/${PR_SLUG}.git` }) |
| 43 | : () => Promise.resolve(), |
| 44 | ]); |
| 45 | |
| 46 | // Restore stashed changes if any |
| 47 | await pop(); |
| 48 | |
| 49 | const args = process.argv.slice(2); |
| 50 | |
| 51 | // Lint all commits in TRAVIS_COMMIT_RANGE if available |
| 52 | if (IS_PR && RANGE) { |
| 53 | const [start, end] = RANGE.split(".").filter(Boolean); |
| 54 | await lint(["--from", start, "--to", end, ...args]); |
| 55 | } else { |
| 56 | const input = await log(COMMIT); |
| 57 | await lint(args, {}, input); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | async function git(args: string[], nodeOptions: SpawnOptions = {}) { |
| 62 | return x(GIT, args, { |