-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
45 lines (38 loc) · 1.22 KB
/
index.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env node
import { Command } from 'commander';
import fs from 'node:fs';
import { install } from './commands/install.js';
import { uninstall } from './commands/uninstall.js';
import { clean } from './commands/clean.js';
import { readConfig } from './utils/config.js';
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const config = readConfig('.merge-drivers.yml');
const program = new Command();
program
.description(packageJson.description)
.version(packageJson.version, '-v, --version', 'Output the current version');
program
.command('install')
.description('Installs merge drivers')
.argument('[merge drivers...]')
.option('-nc, --no-clean', 'Skip cleaning merge drivers before installing')
.action(async (mergeDrivers, options) => {
if (options.clean) {
await clean(config);
}
await install(config, mergeDrivers);
});
program
.command('uninstall')
.description('Uninstalls merge drivers')
.argument('[merge drivers...]')
.action((mergeDrivers) => {
uninstall(config, mergeDrivers);
});
program
.command('clean')
.description('Cleans merge drivers by uninstalling disabled ones')
.action(() => {
clean(config);
});
program.parse(process.argv);