Skip to content

chore: update inquirer to the latest version #3959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/common/commands/proxy/proxy-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ProxyCommandBase } from "./proxy-base";
import { HttpProtocolToPort } from "../../constants";
import { parse } from "url";
import { platform, EOL } from "os";
import * as prompt from "inquirer";
const { getCredentialsFromAuth } = require("proxy-lib/lib/utils");

const proxySetCommandName = "proxy|set";
Expand Down Expand Up @@ -121,7 +122,7 @@ export class ProxySetCommand extends ProxyCommandBase {

private async getPortFromUserInput(): Promise<number> {
const schemaName = "port";
const schema: IPromptSchema = {
const schema: prompt.Question = {
message: "Port",
type: "input",
name: schemaName,
Expand Down
8 changes: 0 additions & 8 deletions lib/common/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,14 +721,6 @@ interface IPrompterOptions extends IAllowEmpty {
defaultAction?: () => string
}

interface IPrompter extends IDisposable {
get(schemas: IPromptSchema[]): Promise<any>;
getPassword(prompt: string, options?: IAllowEmpty): Promise<string>;
getString(prompt: string, options?: IPrompterOptions): Promise<string>;
promptForChoice(promptMessage: string, choices: any[]): Promise<string>;
confirm(prompt: string, defaultAction?: () => boolean): Promise<boolean>;
}

interface IAnalyticsSettingsService {
canDoRequest(): Promise<boolean>;
getUserId(): Promise<string>;
Expand Down
295 changes: 0 additions & 295 deletions lib/common/definitions/prompt.d.ts

This file was deleted.

31 changes: 10 additions & 21 deletions lib/common/prompter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,34 @@ export class Prompter implements IPrompter {
}
}

public async get(schemas: IPromptSchema[]): Promise<any> {
let promptResult: any;

public async get(questions: prompt.Question[]): Promise<any> {
try {
promptResult = await new Promise<any>((resolve, reject) => {
this.muteStdout();

if (!helpers.isInteractive()) {
if (_.some(schemas, s => !s.default)) {
reject(new Error("Console is not interactive and no default action specified."));
if (_.some(questions, s => !s.default)) {
throw new Error("Console is not interactive and no default action specified.");
} else {
const result: any = {};

_.each(schemas, s => {
_.each(questions, s => {
// Curly brackets needed because s.default() may return false and break the loop
result[s.name] = s.default();
});

resolve(result);
return result;
}
} else {
prompt.prompt(schemas, (result: any) => {
if (result) {
resolve(result);
} else {
reject(new Error(`Unable to get result from prompt: ${result}`));
}
});
const result = await prompt.prompt(questions);
return result;
}
});
} finally {
this.unmuteStdout();
}

return promptResult;
}

public async getPassword(prompt: string, options?: IAllowEmpty): Promise<string> {
const schema: IPromptSchema = {
const schema: prompt.Question = {
message: prompt,
type: "password",
name: "password",
Expand All @@ -67,7 +56,7 @@ export class Prompter implements IPrompter {
}

public async getString(prompt: string, options?: IPrompterOptions): Promise<string> {
const schema: IPromptSchema = {
const schema: prompt.Question = {
message: prompt,
type: "input",
name: "inputString",
Expand All @@ -83,7 +72,7 @@ export class Prompter implements IPrompter {
}

public async promptForChoice(promptMessage: string, choices: any[]): Promise<string> {
const schema: IPromptSchema = {
const schema: prompt.Question = {
message: promptMessage,
type: "list",
name: "userAnswer",
Expand Down
Loading