Skip to content

Commit

Permalink
add diff script
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Apr 29, 2021
1 parent 87f58ea commit 7569c47
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions scripts/diff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const {spawnSync} = require('child_process')
const inquirer = require('inquirer')
const glob = require('glob')

async function go() {
const files = glob
.sync('src/+(exercise|final)/*.+(js|ts|tsx)', {
ignore: ['*.d.ts'],
})
.map(f => f.replace(/^src\//, ''))
const {first} = await inquirer.prompt([
{
name: 'first',
message: `What's the first file`,
type: 'list',
choices: files,
},
])
const {second} = await inquirer.prompt([
{
name: 'second',
message: `What's the second file`,
type: 'list',
choices: files.filter(f => f !== first),
},
])

spawnSync(`git diff --no-index ./src/${first} ./src/${second}`, {
shell: true,
stdio: 'inherit',
})
}

go()

0 comments on commit 7569c47

Please sign in to comment.