Skip to content

Instantly share code, notes, and snippets.

@kentcdodds
Created April 29, 2021 17:23
Show Gist options
  • Save kentcdodds/b5d1281efac0bc3846a9724f9933828b to your computer and use it in GitHub Desktop.
Save kentcdodds/b5d1281efac0bc3846a9724f9933828b to your computer and use it in GitHub Desktop.
A git diff for EpicReact workshops
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment