From c7160c08704e5645c1b5c6b9426c07fae4c20391 Mon Sep 17 00:00:00 2001 From: Keith Kelly Date: Mon, 18 Jun 2018 22:07:45 -0400 Subject: [PATCH] Use stderr for prompts to better allow scripting (#14) * Update invocations of inquirer.js prompts to output prompt to stderr. fixes #7 * Updates to use updated typings from @types/inquirer --- package-lock.json | 8 ++++---- package.json | 2 +- src/commands/export.command.ts | 2 +- src/commands/login.command.ts | 8 ++++---- src/commands/unlock.command.ts | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 43c82bc5b6..80c57d8a24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@bitwarden/cli", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -23,9 +23,9 @@ } }, "@types/inquirer": { - "version": "0.0.41", - "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-0.0.41.tgz", - "integrity": "sha512-kIWkK3FECGKt9OrURxRvi59gwMNiWTePXWOvaJn+xhplbEvu91hIDMfLe5PUu+cEEMmD6EFU4VFJJKKp5kzCtw==", + "version": "0.0.42", + "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-0.0.42.tgz", + "integrity": "sha512-flMaNWU2g9NrtZ4bIV+7SEY2W7OdWNNhmJ0rE1lWVxGrkp3TfFGMcFCxRIBmGWigI8e6n+2HqLjizTTfgcpHLg==", "dev": true, "requires": { "@types/rx": "4.1.1", diff --git a/package.json b/package.json index d3bf3ea6ca..4943ad7562 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "devDependencies": { "@types/commander": "^2.12.2", "@types/form-data": "^2.2.1", - "@types/inquirer": "^0.0.41", + "@types/inquirer": "^0.0.42", "@types/lowdb": "^1.0.1", "@types/lunr": "^2.1.5", "@types/node": "^10.0.8", diff --git a/src/commands/export.command.ts b/src/commands/export.command.ts index f045e3ec2f..c2e5f4b17f 100644 --- a/src/commands/export.command.ts +++ b/src/commands/export.command.ts @@ -19,7 +19,7 @@ export class ExportCommand { async run(password: string, cmd: program.Command): Promise { if (password == null || password === '') { - const answer = await inquirer.prompt({ + const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({ type: 'password', name: 'password', message: 'Master password:', diff --git a/src/commands/login.command.ts b/src/commands/login.command.ts index 631ce8357c..b9fd878cf6 100644 --- a/src/commands/login.command.ts +++ b/src/commands/login.command.ts @@ -22,7 +22,7 @@ export class LoginCommand { async run(email: string, password: string, cmd: program.Command) { if (email == null || email === '') { - const answer = await inquirer.prompt({ + const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({ type: 'input', name: 'email', message: 'Email address:', @@ -37,7 +37,7 @@ export class LoginCommand { } if (password == null || password === '') { - const answer = await inquirer.prompt({ + const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({ type: 'password', name: 'password', message: 'Master password:', @@ -89,7 +89,7 @@ export class LoginCommand { const options = twoFactorProviders.map((p) => p.name); options.push(new inquirer.Separator()); options.push('Cancel'); - const answer = await inquirer.prompt({ + const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({ type: 'list', name: 'method', message: 'Two-step login method:', @@ -111,7 +111,7 @@ export class LoginCommand { } if (twoFactorToken == null) { - const answer = await inquirer.prompt({ + const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({ type: 'input', name: 'token', message: 'Two-step login code:', diff --git a/src/commands/unlock.command.ts b/src/commands/unlock.command.ts index d941359027..288ea91e69 100644 --- a/src/commands/unlock.command.ts +++ b/src/commands/unlock.command.ts @@ -16,7 +16,7 @@ export class UnlockCommand { async run(password: string, cmd: program.Command) { if (password == null || password === '') { - const answer = await inquirer.prompt({ + const answer: inquirer.Answers = await inquirer.createPromptModule({ output: process.stderr })({ type: 'password', name: 'password', message: 'Master password:',