heapwolf / prompt-sync

a synchronous prompt for node.js
MIT License
211 stars 42 forks source link

Marking Repo as Deprecated and Offering Alternatives #58

Open joshuabremerdexcom opened 2 years ago

joshuabremerdexcom commented 2 years ago

This repo has a vulnerability that isn't being addressed. This repo seems abandoned. I wanted to offer an alternative that is working well for me with the readline sync package (https://github.com/anseki/readline-sync#utility_methods-keyinyn):

Before:

const prompt = require('prompt-sync')();
prompt('> ')

After using readline-sync:

const readlineSync = require('readline-sync');
const answer = readlineSync.prompt();
BenSjoberg commented 2 years ago

Came here looking for an alternative after noticing the npm audit warning. Thanks for sharing!

phunanon commented 8 months ago

readline-sync seems now, itself, deprecated.

dave-kennedy commented 3 months ago

The node:readline module looks like it's easy enough to use by itself:

import * as readline from 'node:readline/promises';
import { stdin as input, stdout as output } from 'node:process';

const rl = readline.createInterface({ input, output });

const answer = await rl.question('What do you think of Node.js? ');

console.log(`Thank you for your valuable feedback: ${answer}`);

rl.close();

See https://nodejs.org/docs/latest-v20.x/api/readline.html.