UNPKG

2.1 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 });
12const remaining_flags_1 = require("../lib/utils/remaining-flags");
13const abstract_command_1 = require("./abstract.command");
14class AddCommand extends abstract_command_1.AbstractCommand {
15 load(program) {
16 program
17 .command('add <library>')
18 .allowUnknownOption()
19 .description('Adds support for an external library to your project.')
20 .option('-d, --dry-run', 'Report actions that would be performed without writing out results.')
21 .option('-p, --project [project]', 'Project in which to generate files.')
22 .usage('<library> [options] [library-specific-options]')
23 .action((library, command) => __awaiter(this, void 0, void 0, function* () {
24 const options = [];
25 options.push({ name: 'dry-run', value: !!command.dryRun });
26 options.push({
27 name: 'project',
28 value: command.project,
29 });
30 const inputs = [];
31 inputs.push({ name: 'library', value: library });
32 const flags = remaining_flags_1.getRemainingFlags(program);
33 try {
34 yield this.action.handle(inputs, options, flags);
35 }
36 catch (err) {
37 process.exit(0);
38 }
39 }));
40 }
41}
42exports.AddCommand = AddCommand;