forked from sveltejs/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.ts
More file actions
25 lines (20 loc) · 934 Bytes
/
bin.ts
File metadata and controls
25 lines (20 loc) · 934 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
#!/usr/bin/env node
import { program } from 'commander';
import process from 'node:process';
import pkg from './package.json' with { type: 'json' };
import { add } from './src/cli/add.ts';
import { check } from './src/cli/check.ts';
import { create } from './src/cli/create.ts';
import { migrate } from './src/cli/migrate.ts';
import { helpConfig } from './src/core/common.ts';
// adds a gap of spacing between the executing command and the output
console.log();
program.name(pkg.name).version(pkg.version, '-v, --version').configureHelp(helpConfig);
program.addCommand(create).addCommand(add).addCommand(migrate).addCommand(check);
// sv --help: show sv + create (which includes the addon reference)
// sv (bare): just the command list
const hasHelpFlag = process.argv.includes('--help') || process.argv.includes('-h');
if (hasHelpFlag) {
program.addHelpText('after', () => '\n' + create.helpInformation());
}
program.parse();