|
4 | 4 | */ |
5 | 5 |
|
6 | 6 | const argv = require('minimist')(process.argv.slice(2)); |
7 | | -const commander = require('commander'); |
| 7 | +const {program} = require('commander'); |
8 | 8 | const esprima = require('esprima'); |
9 | 9 | const fs = require('fs-extra'); |
10 | 10 | const os = require('os'); |
@@ -218,15 +218,15 @@ function createTask( |
218 | 218 | argv._.length === 0 && taskName == 'default' && !isHelpTask; // `amp` |
219 | 219 |
|
220 | 220 | if (isHelpTask) { |
221 | | - const task = commander.command(cyan(taskName)); |
| 221 | + const task = program.command(cyan(taskName)); |
222 | 222 | const description = getTaskDescription(taskSourceFileName, taskFuncName); |
223 | 223 | task.description(description); |
224 | 224 | } |
225 | 225 | if (isInvokedTask || isDefaultTask) { |
226 | 226 | startAtRepoRoot(); |
227 | 227 | ensureUpdatedPackages(taskSourceFileName); |
228 | 228 | const taskFunc = getTaskFunc(taskSourceFileName, taskFuncName); |
229 | | - const task = commander.command(taskName, {isDefault: isDefaultTask}); |
| 229 | + const task = program.command(taskName, {isDefault: isDefaultTask}); |
230 | 230 | task.description(green(taskFunc.description)); |
231 | 231 | task.allowUnknownOption(); // Fall through to validateUsage() |
232 | 232 | task.helpOption('--help', 'Print this list of flags'); |
@@ -267,18 +267,18 @@ function validateUsage(task, taskName, taskFunc) { |
267 | 267 | * was called. |
268 | 268 | */ |
269 | 269 | function finalizeRunner() { |
270 | | - commander.addHelpCommand(false); // We already have `amp --help` and `amp <task> --help` |
| 270 | + program.addHelpCommand(false); // We already have `amp --help` and `amp <task> --help` |
271 | 271 | if (isHelpTask) { |
272 | | - commander.helpOption('--help', 'Print this list of tasks'); |
273 | | - commander.usage('<task> <flags>'); |
| 272 | + program.helpOption('--help', 'Print this list of tasks'); |
| 273 | + program.usage('<task> <flags>'); |
274 | 274 | } |
275 | | - commander.on('command:*', (args) => { |
| 275 | + program.on('command:*', (args) => { |
276 | 276 | log(red('ERROR:'), 'Unknown task', cyan(args.join(' '))); |
277 | 277 | log('⤷ Run', cyan('amp --help'), 'for a full list of tasks.'); |
278 | 278 | log('⤷ Run', cyan('amp <task> --help'), 'for help with a specific task.'); |
279 | 279 | process.exitCode = 1; |
280 | 280 | }); |
281 | | - commander.parse(); |
| 281 | + program.parse(); |
282 | 282 | } |
283 | 283 |
|
284 | 284 | module.exports = { |
|
0 commit comments