Created
April 29, 2021 17:23
-
-
Save kentcdodds/b5d1281efac0bc3846a9724f9933828b to your computer and use it in GitHub Desktop.
A git diff for EpicReact workshops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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