forked from rollup/rollup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.ts
31 lines (28 loc) · 888 Bytes
/
cli.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
25
26
27
28
29
30
31
#!/usr/bin/env node
import process from 'node:process';
import help from 'help.md';
import { version } from 'package.json';
import argParser from 'yargs-parser';
import { commandAliases } from '../src/utils/options/mergeOptions';
import run from './run/index';
const command = argParser(process.argv.slice(2), {
alias: commandAliases,
configuration: { 'camel-case-expansion': false }
});
if (command.help || (process.argv.length <= 2 && process.stdin.isTTY)) {
console.log(`\n${help.replace('__VERSION__', version)}\n`);
} else if (command.version) {
console.log(`rollup v${version}`);
} else {
try {
// eslint-disable-next-line unicorn/prefer-module
require('source-map-support').install();
} catch {
// do nothing
}
const promise = run(command);
if (command.forceExit) {
// eslint-disable-next-line unicorn/no-process-exit
promise.then(() => process.exit());
}
}