Socket
Socket
Sign inDemoInstall

heroku-cli-util

Package Overview
Dependencies
Maintainers
19
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heroku-cli-util - npm Package Compare versions

Comparing version 6.0.7 to 6.0.8

.nyc_output/1659.json

31

lib/command.js

@@ -122,17 +122,18 @@ 'use strict'

let run = function () {
return fn(context, heroku(context))
.catch(function (err) {
if (err && err.body && err.body.id === 'unauthorized') {
cli.error(err.body.message || 'Unauthorized')
relogin()
.then(apiKey => { context.auth = {password: apiKey} })
.then(run)
.catch(handleErr)
} else if (err && err.body && err.body.id === 'sudo_reason_required') {
cli.warn(err.body.message)
reasonPrompt(context).then(run).catch(handleErr)
} else if (err && err.body && err.body.id === 'two_factor') {
twoFactorPrompt(options, context).then(run).catch(handleErr)
} else throw err
}).catch(handleErr)
let p = fn(context, heroku(context))
if (!p.catch) return
p.catch(function (err) {
if (err && err.body && err.body.id === 'unauthorized') {
cli.error(err.body.message || 'Unauthorized')
relogin()
.then(apiKey => { context.auth = {password: apiKey} })
.then(run)
.catch(handleErr)
} else if (err && err.body && err.body.id === 'sudo_reason_required') {
cli.warn(err.body.message)
reasonPrompt(context).then(run).catch(handleErr)
} else if (err && err.body && err.body.id === 'two_factor') {
twoFactorPrompt(options, context).then(run).catch(handleErr)
} else throw err
}).catch(handleErr)
}

@@ -139,0 +140,0 @@ return run()

'use strict'
let cli = require('../')
let errors = require('./errors')
let util = require('./util')
const cli = require('../')
const errors = require('./errors')
const util = require('./util')
const color = require('./color')
const ansi = require('ansi-escapes')
function promptMasked (options) {
function refresh (input, mask) {
process.stderr.clearLine()
process.stderr.cursorTo(0)
process.stderr.write(options.prompt + (mask ? input.replace(/./g, '*') : input))
}
return new Promise(function (resolve, reject) {
let stdin = process.stdin
let stderr = process.stderr
let input = ''
if (!stdin.isTTY) {
throw new Error(`Error: CLI needs to prompt for ${options.name || options.prompt} but stdin is not a tty.`)
}
stdin.setEncoding('utf8')
stderr.write(ansi.eraseLine)
stderr.write(ansi.cursorLeft)
stderr.write(options.prompt)
stdin.resume()
stdin.setRawMode(true)
function start () {
process.stdin.setEncoding('utf8')
process.stderr.write(options.prompt)
process.stdin.resume()
if (!process.stdin.isTTY) {
throw new Error(`need to prompt for ${options.name || options.prompt} but stdin is not a tty`)
function stop () {
if (!options.hide) {
stderr.write(
ansi.cursorHide +
ansi.cursorLeft +
options.prompt +
input.replace(/./g, '*') +
'\n' +
ansi.cursorShow)
} else {
stderr.write('\n')
}
stdin.removeListener('data', fn)
stdin.setRawMode(false)
stdin.pause()
}
process.stdin.setRawMode(true)
}
function stop () {
console.error()
process.stdin.setRawMode(false)
process.stdin.pause()
}
function enter () {
if (input.length === 0) return
stop()
resolve(input)
}
return new Promise(function (resolve, reject) {
start()
let input = ''
function ctrlc () {
reject('')
stop()
}
function backspace () {
if (input.length === 0) return
input = input.substr(0, input.length - 1)
stderr.write(ansi.cursorBackward(1))
stderr.write(ansi.eraseEndLine)
}
function newchar (c) {
input += c
stderr.write(options.hide ? '*' : c)
}
let fn = function (c) {

@@ -38,23 +69,12 @@ switch (c) {

case '\n':
if (input.length === 0) return
refresh(input, true)
stop()
process.stdin.removeListener('data', fn)
resolve(input)
return
case '\u0003':
// Ctrl-c
reject('')
stop()
process.stdin.removeListener('data', fn)
return
return enter()
case '\u0003': // Ctrl-c
return ctrlc()
default:
// backspace
if (c.charCodeAt(0) === 127) input = input.substr(0, input.length - 1)
else input += c
refresh(input, options.hide)
return
if (c.charCodeAt(0) === 127) return backspace()
else return newchar(c)
}
}
process.stdin.on('data', fn)
stdin.on('data', fn)
})

@@ -65,3 +85,4 @@ }

options = options || {}
options.prompt = name ? name + ': ' : '> '
options.name = name
options.prompt = name ? color.gray(`${name}: `) : color.gray('> ')
if (options.mask || options.hide) return promptMasked(options)

@@ -68,0 +89,0 @@ return new Promise(function (resolve) {

{
"name": "heroku-cli-util",
"description": "Set of helpful CLI utilities",
"version": "6.0.7",
"version": "6.0.8",
"author": "Jeff Dickey (@dickeyxxx)",

@@ -6,0 +6,0 @@ "bugs": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc