Skip to content

Commit

Permalink
tweak api-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Dec 4, 2023
1 parent dae2057 commit 5e11fd8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/deno/api-diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function getPrRange(prNum: number) {

async function genForCommit(commit: string, force: boolean) {
const tmpDir = `/tmp/api-diff/${commit}`
const alreadyExists = await exists(tmpDir)
const alreadyExists = await exists(tmpDir + '/Api.ts')

// if the directory already exists, skip it
if (force || !alreadyExists) {
Expand All @@ -100,6 +100,9 @@ async function genForCommit(commit: string, force: boolean) {

if (!$.commandExistsSync('gh')) throw Error('Need gh (GitHub CLI)')

// prefer difftastic if it exists. https://difftastic.wilfred.me.uk/
const diffTool = $.commandExistsSync('difft') ? 'difft' : 'diff'

const args = flags.parse(Deno.args, {
alias: { force: ['f'], h: 'help' },
boolean: ['force', 'help'],
Expand All @@ -118,5 +121,4 @@ const { base, head } = await getPrRange(prNum)
const tmpDirBase = await genForCommit(base, args.force)
const tmpDirHead = await genForCommit(head, args.force)

// git difftool is a trick to diff with whatever you have git set to use
await $`git --no-pager difftool ${tmpDirBase}/Api.ts ${tmpDirHead}/Api.ts || true`
await $`${diffTool} ${tmpDirBase}/Api.ts ${tmpDirHead}/Api.ts || true`

0 comments on commit 5e11fd8

Please sign in to comment.