UNPKG

@codification/cutwater-build-aws

Version:
79 lines 3.34 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AwsCliTask = void 0; const cutwater_build_core_1 = require("@codification/cutwater-build-core"); const CliUtils_1 = require("../support/CliUtils"); class AwsCliTask extends cutwater_build_core_1.GulpTask { constructor(taskName = 'aws-cli', command = '', subCommand = '', filteredParams = [], defaultConfig = {}) { super(taskName, Object.assign({ spawn: cutwater_build_core_1.Spawn.create(), spawnOptions: { command: 'aws', quiet: false, ignoreErrors: false, cwd: process.cwd(), env: {}, } }, defaultConfig)); this.awsCommand = command; this.awsSubCommand = subCommand; this.filteredParams = filteredParams; } setConfig(taskConfig) { if (!this.config) { this.config = {}; } if (!!taskConfig.spawnOptions) { this.setSpawnOptions(taskConfig.spawnOptions); } if (!!taskConfig.options) { this.setOptions(taskConfig.options); } if (!!taskConfig.parameters) { this.setParameters(taskConfig.parameters); } } replaceConfig(taskConfig) { this.config = taskConfig; } setSpawnOptions(options) { this.config.spawnOptions = Object.assign(Object.assign({}, this.config.spawnOptions), options); } replaceSpawnOptions(options) { this.config.spawnOptions = options; } setOptions(options) { this.config.options = Object.assign(Object.assign({}, this.config.options), options); } replaceOptions(options) { this.config.options = options; } setParameters(parameters) { this.config.parameters = Object.assign(Object.assign({}, this.config.parameters), parameters); } replaceParameters(parameters) { this.config.parameters = parameters; } setArguments(args) { this.config.args = args; } executeTask() { return __awaiter(this, void 0, void 0, function* () { const args = CliUtils_1.CliUtils.prepareArgs(this.config, { command: this.awsCommand, subCommand: this.awsSubCommand, filteredParams: this.filteredParams, }); this.log(`Running: ${this.config.spawnOptions.command} ${args}`); this.output = yield this.config.spawn.execute(Object.assign(Object.assign({ logger: this.logger() }, this.config.spawnOptions), { args })); }); } } exports.AwsCliTask = AwsCliTask; //# sourceMappingURL=AwsCliTask.js.map