Easy Confirmation Prompt for Node.js CLI Script
Prompt the user if they'd like to continue when executing a Node.js script from the command line.
The tldr:
import { createInterface } from 'node:readline/promises'
import { exit, stdin, stdout } from 'node:process'
const rl = createInterface({ input: stdin, output: stdout })
const answer = await rl.question('You sure? (y/n) ')
rl.close()
if (answer.toLowerCase() !== 'y') exit(0)
That's it actually.
from Sanity.io (195.84ms) to HTML (2.36ms)