Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@poppinss/prompts

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@poppinss/prompts - npm Package Compare versions

Comparing version 3.1.0-0 to 3.1.0-1

8

build/src/base.d.ts

@@ -5,4 +5,10 @@ import { PromptChoice, ListPromptOptions, TextPromptOptions, TogglePromptOptions, ChoicePromptOptions, BooleanPromptOptions, MultiplePromptOptions, AutoCompletePromptOptions } from './types.js';

#private;
traps: {
prompts: Map<string, {
prompt: MockedPrompt;
triggerError: Error;
}>;
verify: () => void;
};
protected abstract prompt(options: any): Promise<any>;
get traps(): string[];
ask<Result extends any = string>(title: string, options?: TextPromptOptions<Result>): Promise<Result>;

@@ -9,0 +15,0 @@ list<Result extends any = string[]>(title: string, options?: ListPromptOptions<Result>): Promise<Result>;

27

build/src/base.js

@@ -6,12 +6,19 @@ import { ObjectBuilder } from '@poppinss/utils';

export class BasePrompt {
#mockedPrompts = new Map();
traps = {
prompts: new Map(),
verify() {
this.prompts.forEach((entry) => {
throw entry.triggerError;
});
},
};
#handlePrompt(options) {
let mockedPrompt;
if (this.#mockedPrompts.has(options.name)) {
mockedPrompt = this.#mockedPrompts.get(options.name);
this.#mockedPrompts.delete(options.name);
if (this.traps.prompts.has(options.name)) {
mockedPrompt = this.traps.prompts.get(options.name).prompt;
this.traps.prompts.delete(options.name);
}
else if (this.#mockedPrompts.has(options.message)) {
mockedPrompt = this.#mockedPrompts.get(options.message);
this.#mockedPrompts.delete(options.message);
else if (this.traps.prompts.has(options.message)) {
mockedPrompt = this.traps.prompts.get(options.message).prompt;
this.traps.prompts.delete(options.message);
}

@@ -23,5 +30,2 @@ if (mockedPrompt) {

}
get traps() {
return Array.from(this.#mockedPrompts.keys());
}
async ask(title, options) {

@@ -174,6 +178,7 @@ options = options || {};

trap(message) {
const triggerError = new Error(`Expected prompt "${message}" to get triggered`);
const mockedPrompt = new MockedPrompt();
this.#mockedPrompts.set(message, mockedPrompt);
this.traps.prompts.set(message, { prompt: mockedPrompt, triggerError });
return mockedPrompt;
}
}
{
"name": "@poppinss/prompts",
"version": "3.1.0-0",
"version": "3.1.0-1",
"description": "Wrapper over enquirer with better support for testing",

@@ -5,0 +5,0 @@ "main": "build/index.js",

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