-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathgit-node.js
More file actions
executable file
·32 lines (25 loc) · 905 Bytes
/
git-node.js
File metadata and controls
executable file
·32 lines (25 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env node
import { readdirSync } from 'fs';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import epilogue from '../components/git/epilogue.js';
import { setVerbosityFromEnv } from '../lib/verbosity.js';
setVerbosityFromEnv();
const commandFiles = readdirSync(new URL('../components/git', import.meta.url))
.filter(file => file !== 'epilogue.js');
function importCommand(commandFile) {
return import(new URL(`../components/git/${commandFile}`, import.meta.url));
}
Promise.all(commandFiles.map(importCommand)).then((commands) => {
const args = yargs(hideBin(process.argv));
commands.forEach(command => args.command(command));
args.command('help', false, () => {}, (yargs) => { yargs.showHelp(); })
.completion('completion')
.demandCommand(1)
.strict()
.epilogue(epilogue)
.help('help')
.parse();
}).catch((err) => {
throw err;
});