Skip to content

Commit 5e11fd8

Browse files
committed
tweak api-diff
1 parent dae2057 commit 5e11fd8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/deno/api-diff.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async function getPrRange(prNum: number) {
8181

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

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

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

103+
// prefer difftastic if it exists. https://difftastic.wilfred.me.uk/
104+
const diffTool = $.commandExistsSync('difft') ? 'difft' : 'diff'
105+
103106
const args = flags.parse(Deno.args, {
104107
alias: { force: ['f'], h: 'help' },
105108
boolean: ['force', 'help'],
@@ -118,5 +121,4 @@ const { base, head } = await getPrRange(prNum)
118121
const tmpDirBase = await genForCommit(base, args.force)
119122
const tmpDirHead = await genForCommit(head, args.force)
120123

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

0 commit comments

Comments
 (0)