Browse Source

Show the period when prompting for a domain purchase

master
Matheus Fernandes 8 years ago
parent
commit
dd1071366d
No known key found for this signature in database GPG Key ID: DD07CA4EA7B65C4F
  1. 6
      bin/domains/buy.js
  2. 5
      lib/alias.js
  3. 2
      lib/domains.js

6
bin/domains/buy.js

@ -24,7 +24,7 @@ module.exports = async function({ domains, args, currentTeam, user }) {
elapsed = stamp() elapsed = stamp()
let stopSpinner = wait(`Checking availability for ${nameParam}`) let stopSpinner = wait(`Checking availability for ${nameParam}`)
const price = await domains.price(name) const { price, period } = await domains.price(name)
const available = await domains.status(name) const available = await domains.status(name)
stopSpinner() stopSpinner()
@ -34,10 +34,10 @@ module.exports = async function({ domains, args, currentTeam, user }) {
`The domain ${nameParam} is ${italic('unavailable')}! ${elapsed()}` `The domain ${nameParam} is ${italic('unavailable')}! ${elapsed()}`
) )
} }
const periodMsg = `${period}yr${period > 1 ? 's' : ''}, `
info(`The domain ${nameParam} is ${italic('available')}! ${elapsed()}`) info(`The domain ${nameParam} is ${italic('available')}! ${elapsed()}`)
const confirmation = await promptBool( const confirmation = await promptBool(
`Buy now for ${bold(`$${price}`)} (${bold((currentTeam && currentTeam.slug) || user.username || user.email)})?` `Buy now for ${bold(`$${price}`)} (${bold(periodMsg + (currentTeam && currentTeam.slug) || user.username || user.email)})?`
) )
eraseLines(1) eraseLines(1)

5
lib/alias.js

@ -546,12 +546,13 @@ module.exports = class Alias extends Now {
stopSpinner() stopSpinner()
if (canBePurchased) { if (canBePurchased) {
const price = await pricePromise const { price, period } = await pricePromise
const periodMsg = `${period}yr${period > 1 ? 's' : ''}, `
info( info(
`The domain ${aliasParam} is ${chalk.bold('available for purchase')}! ${elapsed()}` `The domain ${aliasParam} is ${chalk.bold('available for purchase')}! ${elapsed()}`
) )
const confirmation = await promptBool( const confirmation = await promptBool(
`Buy now for ${chalk.bold(`$${price}`)} (${chalk.bold((currentTeam && currentTeam.slug) || user.username || user.email)})?` `Buy now for ${chalk.bold(`$${price}`)} (${chalk.bold(periodMsg + (currentTeam && currentTeam.slug) || user.username || user.email)})?`
) )
eraseLines(1) eraseLines(1)
if (!confirmation) { if (!confirmation) {

2
lib/domains.js

@ -125,7 +125,7 @@ module.exports = class Domains extends Now {
console.timeEnd(`> [debug] #${attempt} GET /domains/price?${query}`) console.timeEnd(`> [debug] #${attempt} GET /domains/price?${query}`)
} }
return json.price return json
}) })
} }

Loading…
Cancel
Save