npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@prompt-or-die/core

v1.0.0

Published

A utility package for prompting users with critical decisions - exit on denial

Downloads

3

Readme

@prompt-or-die/core

A utility package for prompting users with critical decisions. If the user doesn't confirm with the expected input, the process exits immediately.

Perfect for deployment scripts, database migrations, file deletions, and other critical operations where user confirmation is mandatory.

Installation

npm install @prompt-or-die/core

Quick Start

const { promptOrDie } = require('@prompt-or-die/core');

// Basic usage - exits if user doesn't type "yes"
promptOrDie('Are you sure you want to delete all files?');

// Custom confirmation text
promptOrDie('Type "DELETE" to proceed with deletion', 'DELETE');

// With callback for post-confirmation actions
promptOrDie('Continue with deployment?', 'yes', () => {
  console.log('Starting deployment...');
  // Your critical code here
});

API Reference

promptOrDie(message, confirmText, callback)

Prompts the user and exits the process if they don't provide exact confirmation.

  • message (string): The message to display to the user
  • confirmText (string, optional): The text user must type to confirm (default: 'yes')
  • callback (function, optional): Function to execute after confirmation

Example:

promptOrDie('Delete production database?', 'CONFIRM DELETE', () => {
  // This only runs if user types "CONFIRM DELETE"
  deleteDatabase();
});

confirm(message, confirmText)

Promise-based version that resolves on confirmation or exits on denial.

  • message (string): The message to display to the user
  • confirmText (string, optional): The text user must type to confirm (default: 'yes')
  • Returns: Promise - Always resolves to true (exits process if false)

Example:

async function deploy() {
  await confirm('Deploy to production?');
  console.log('Deploying...');
  // Deployment code here
}

promptOrDieSync(message, confirmText)

Synchronous version (requires readline-sync as dependency).

  • message (string): The message to display to the user
  • confirmText (string, optional): The text user must type to confirm (default: 'yes')

Example:

// Install readline-sync first: npm install readline-sync
promptOrDieSync('Proceed with migration?');
console.log('User confirmed, continuing...');

Use Cases

  • 🚀 Deployment confirmations - Prevent accidental production deployments
  • 🗄️ Database migrations - Ensure critical schema changes are intentional
  • 🗑️ File deletions - Confirm before removing important files
  • 🔄 Environment switches - Verify before switching to production
  • ⚠️ Critical operations - Any irreversible action requiring explicit consent

Behavior

  • Confirmed: If user types the exact confirmation text (case-insensitive), execution continues
  • Denied: If user types anything else, presses Enter without input, or provides wrong text, the process exits with code 1

Why Use This?

Traditional prompts often accept "y", "Y", "yes", or just Enter. This can lead to accidental confirmations. @prompt-or-die/core requires exact text matches, making accidental confirmations nearly impossible.

Security Note

This package is designed for interactive scripts and should not be used in production servers or automated environments where user input isn't available.

Contributing

Issues and pull requests are welcome! Visit our GitHub repository.

License

ISC License - see LICENSE file for details.


⚠️ Remember: This package will exit your process immediately if the user doesn't confirm. Use it wisely!