Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async run() {
const {args, flags} = this.parse(Remove)
const buildpackCommand = new BuildpackCommand(this.heroku)
if (flags.index && args.buildpack) {
cli.error('Please choose either index or Buildpack, but not both.', {exit: 1})
}
if (!flags.index && !args.buildpack) {
cli.error('Usage: heroku buildpacks:remove [BUILDPACK_URL]. Must specify a buildpack to remove, either by index or URL.')
}
const buildpacks = await buildpackCommand.fetch(flags.app)
if (buildpacks.length === 0) {
cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, {exit: 1})
}
let spliceIndex: number
if (flags.index) {
buildpackCommand.validateIndexInRange(buildpacks, flags.index)
spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index)
} else {
spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack)
async run() {
const {args, flags} = this.parse(Remove)
const buildpackCommand = new BuildpackCommand(this.heroku)
if (flags.index && args.buildpack) {
cli.error('Please choose either index or Buildpack, but not both.', {exit: 1})
}
if (!flags.index && !args.buildpack) {
cli.error('Usage: heroku buildpacks:remove [BUILDPACK_URL]. Must specify a buildpack to remove, either by index or URL.')
}
const buildpacks = await buildpackCommand.fetch(flags.app)
if (buildpacks.length === 0) {
cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, {exit: 1})
}
let spliceIndex: number
if (flags.index) {
buildpackCommand.validateIndexInRange(buildpacks, flags.index)
spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index)
} else {
spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack)
}
if (spliceIndex === -1) {
async run() {
const {args, flags} = this.parse(Remove)
const buildpackCommand = new BuildpackCommand(this.heroku)
if (flags.index && args.buildpack) {
cli.error('Please choose either index or Buildpack, but not both.', {exit: 1})
}
if (!flags.index && !args.buildpack) {
cli.error('Usage: heroku buildpacks:remove [BUILDPACK_URL]. Must specify a buildpack to remove, either by index or URL.')
}
const buildpacks = await buildpackCommand.fetch(flags.app)
if (buildpacks.length === 0) {
cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, {exit: 1})
}
let spliceIndex: number
if (flags.index) {
buildpackCommand.validateIndexInRange(buildpacks, flags.index)
spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index)
} else {
spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack)
}
if (spliceIndex === -1) {
cli.error('Buildpack not found. Nothing was removed.', {exit: 1})
}
if (buildpacks.length === 1) {
await buildpackCommand.clear(flags.app, 'remove', 'removed')
notloggedin () {
cli.error('not logged in', {exitCode: 100})
}
}
Err: err => {
cli.error(`Could not find the buildpack: ${buildpack}. ${err}`, {exit: 1})
},
}, BuildpackRegistry.isValidBuildpackSlug(buildpack))
try {
let response = await this.registry.buildpackExists(buildpack)
let body = await response.json()
return body.blob_url
} catch (err) {
if (err.statusCode === 404) {
cli.error(`${buildpack} is not in the buildpack registry.`, {exit: 1})
} else if (err.statusCode) {
cli.error(`${err.statusCode}: ${err.message}`, {exit: 1})
} else {
cli.error(err.message, {exit: 1})
}
}
return ''
}
Err: err => {
if (err.status === 404) {
cli.error(`Could not find the buildpack '${args.buildpack}'`)
} else {
cli.error(`Problems finding buildpack info: ${err.description}`)
}
}
}, result)
const buildpacks = await buildpackCommand.fetch(flags.app)
if (buildpacks.length === 0) {
cli.error(`No buildpacks were found. Next release on ${flags.app} will detect buildpack normally.`, {exit: 1})
}
let spliceIndex: number
if (flags.index) {
buildpackCommand.validateIndexInRange(buildpacks, flags.index)
spliceIndex = await buildpackCommand.findIndex(buildpacks, flags.index)
} else {
spliceIndex = await buildpackCommand.findUrl(buildpacks, args.buildpack)
}
if (spliceIndex === -1) {
cli.error('Buildpack not found. Nothing was removed.', {exit: 1})
}
if (buildpacks.length === 1) {
await buildpackCommand.clear(flags.app, 'remove', 'removed')
} else {
const buildpackUpdates = await buildpackCommand.mutate(flags.app, buildpacks, spliceIndex, args.buildpack, 'remove')
buildpackCommand.displayUpdate(flags.app, flags.remote || '', buildpackUpdates, 'removed')
}
}
}
parse: input => {
const w = parseInt(input, 10)
if (w < 10) {
cli.error('wait-interval must be at least 10', {exit: 1})
}
return w
},
default: 10,
validateIndexInRange(buildpacks: BuildpackResponse[], index: number) {
if (index < 0 || index > buildpacks.length) {
if (buildpacks.length === 1) {
cli.error('Invalid index. Only valid value is 1.', {exit: 1})
} else {
cli.error(`Invalid index. Please choose a value between 1 and ${buildpacks.length}`, {exit: 1})
}
}
}