UNPKG

2.29 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4 return new (P || (P = Promise))(function (resolve, reject) {
5 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8 step((generator = generator.apply(thisArg, _arguments || [])).next());
9 });
10};
11Object.defineProperty(exports, "__esModule", { value: true });
12exports.AddCommand = void 0;
13const remaining_flags_1 = require("../lib/utils/remaining-flags");
14const abstract_command_1 = require("./abstract.command");
15class AddCommand extends abstract_command_1.AbstractCommand {
16 load(program) {
17 program
18 .command('add <library>')
19 .allowUnknownOption()
20 .description('Adds support for an external library to your project.')
21 .option('-d, --dry-run', 'Report actions that would be performed without writing out results.')
22 .option('-s, --skip-install', 'Skip package installation.', false)
23 .option('-p, --project [project]', 'Project in which to generate files.')
24 .usage('<library> [options] [library-specific-options]')
25 .action((library, command) => __awaiter(this, void 0, void 0, function* () {
26 const options = [];
27 options.push({ name: 'dry-run', value: !!command.dryRun });
28 options.push({ name: 'skip-install', value: command.skipInstall });
29 options.push({
30 name: 'project',
31 value: command.project,
32 });
33 const inputs = [];
34 inputs.push({ name: 'library', value: library });
35 const flags = (0, remaining_flags_1.getRemainingFlags)(program);
36 try {
37 yield this.action.handle(inputs, options, flags);
38 }
39 catch (err) {
40 process.exit(1);
41 }
42 }));
43 }
44}
45exports.AddCommand = AddCommand;