Browse Source

Normalize deployment URLs before removing

This closes #299
master
Leo Lamprecht 8 years ago
parent
commit
d1ce432c65
No known key found for this signature in database GPG Key ID: B08517883D5E0E10
  1. 8
      bin/now-remove.js

8
bin/now-remove.js

@ -5,6 +5,7 @@ const minimist = require('minimist')
const chalk = require('chalk')
const ms = require('ms')
const table = require('text-table')
const isURL = require('is-url')
// Ours
const Now = require('../lib')
@ -127,6 +128,11 @@ async function remove(token) {
const matches = deployments.filter(d => {
return ids.find(id => {
// Normalize URL by removing slash from the end
if (isURL(id) && id.slice(-1) === '/') {
id = id.slice(0, -1)
}
// `url` should match the hostname of the deployment
let u = id.replace(/^https:\/\//i, '')
@ -139,6 +145,8 @@ async function remove(token) {
})
})
process.exit(0)
if (matches.length === 0) {
error(`Could not find any deployments matching ${ids.map(id => chalk.bold(`"${id}"`)).join(', ')}. Run ${chalk.dim(`\`now ls\``)} to list.`)
return process.exit(1)

Loading…
Cancel
Save