-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
24 lines (20 loc) · 1.12 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env node
// Based on https://github.com/vercel/next.js/blob/26a2bab6fa0f0bdf9ff88f85d64342bb5a975658/packages/next-codemod/bin/next-codemod.ts
// @expressjs/codemod optional-name-of-transform optional/path/ [...options]
import { Command } from 'commander'
import { transform } from './commands/transform'
import packageJson from './package.json'
const program = new Command(packageJson.name)
.version(packageJson.version, '-v, --version', `Output the current version of ${packageJson.name}.`)
.description(packageJson.description)
.argument('[codemod]', 'Codemod slug to run')
.argument('[source]', 'Path to source files or directory to transform.')
.helpOption('-h, --help', 'Display this help message.')
.option('-d, --dry', 'Dry run (no changes are made to files)')
.option('-p, --print', 'Print transformed files to stdout')
.option('--verbose', 'Show more information about the transform process')
.usage('[codemod] [source] [options]')
.action(transform)
// Why this option is necessary is explained here: https://github.com/tj/commander.js/pull/1427
.enablePositionalOptions()
program.parse(process.argv)