-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
40 lines (36 loc) · 1.17 KB
/
Copy pathcli.js
File metadata and controls
40 lines (36 loc) · 1.17 KB
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
#!/usr/bin/env node
import { Command } from 'commander';
import process from 'node:process';
import { restoreModules, listModules } from '.';
const program = new Command()
.name('amdex')
.description('CLI tool to restore AMD-style bundles')
.version('1.0.0');
program
.command('restore')
.description('Restore AMD modules from a bundled file')
.requiredOption('-i, --input <path>', 'Input file path')
.option('--include <pattern>', 'Include module pattern (glob or regex)')
.option('--exclude <pattern>', 'Exclude module pattern')
.option('-o, --output <path>', 'Output folder path', './restored')
.action(async (options) => {
try {
await restoreModules(options);
} catch (err) {
console.error('Error:', err instanceof Error ? err.message : String(err));
process.exit(1);
}
});
program
.command('list')
.description('List all possible module paths')
.requiredOption('-i, --input <path>', 'Input file path')
.action(async (options) => {
try {
await listModules(options);
} catch (err) {
console.error('Error:', err instanceof Error ? err.message : String(err));
process.exit(1);
}
});
program.parse();