UNPKG

1.42 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const command_1 = require("@heroku-cli/command");
4const buildpacks_1 = require("../../buildpacks");
5class Set extends command_1.Command {
6 async run() {
7 let { args, flags } = this.parse(Set);
8 let buildpackCommand = new buildpacks_1.BuildpackCommand(this.heroku);
9 let buildpacks = await buildpackCommand.fetch(flags.app);
10 await buildpackCommand.validateUrlNotSet(buildpacks, args.buildpack);
11 let spliceIndex;
12 if (flags.index === undefined) {
13 spliceIndex = 0;
14 }
15 else {
16 let foundIndex = buildpackCommand.findIndex(buildpacks, flags.index);
17 spliceIndex = (foundIndex === -1) ? buildpacks.length : foundIndex;
18 }
19 let buildpackUpdates = await buildpackCommand.mutate(flags.app, buildpacks, spliceIndex, args.buildpack, 'set');
20 buildpackCommand.displayUpdate(flags.app, flags.remote || '', buildpackUpdates, 'set');
21 }
22}
23Set.flags = {
24 app: command_1.flags.app({ required: true }),
25 remote: command_1.flags.remote(),
26 index: command_1.flags.integer({
27 description: 'the 1-based index of the URL in the list of URLs',
28 char: 'i'
29 })
30};
31Set.args = [
32 {
33 name: 'buildpack',
34 required: true,
35 description: 'namespace/name of the buildpack'
36 }
37];
38exports.default = Set;