Socket
Socket
Sign inDemoInstall

is-interactive

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-interactive

Check if stdout or stderr is interactive


Version published
Maintainers
1
Weekly downloads
19,692,086
increased by1.91%
Install size
5.67 kB

Weekly downloads

Package description

What is is-interactive?

The is-interactive npm package is used to check if a Node.js process is running in an interactive environment. This can be particularly useful for CLI applications that need to adapt their behavior based on whether they're running in a background process or directly in a terminal that can accept user input.

What are is-interactive's main functionalities?

Check if the environment is interactive

This feature allows developers to check if the Node.js process is running in an interactive terminal. The function returns a boolean value: `true` if the process is interactive, and `false` otherwise. This can be useful for CLI tools that need to decide whether to prompt the user for input.

const isInteractive = require('is-interactive');

console.log(isInteractive());

Other packages similar to is-interactive

Readme

Source

is-interactive

Check if stdout or stderr is interactive

It checks that the stream is TTY, not a dumb terminal, and not running in a CI.

This can be useful to decide whether to present interactive UI or animations in the terminal.

Install

$ npm install is-interactive

Usage

import isInteractive from 'is-interactive';

isInteractive();
//=> true

API

isInteractive(options?)

options

Type: object

stream

Type: stream.Writable
Default: process.stdout

The stream to check.

FAQ

Why are you not using ci-info for the CI check?

It's silly to have to detect individual CIs. They should identify themselves with the CI environment variable, and most do just that. A manually maintained list of detections will easily get out of date. And if a package using ci-info doesn't update to the latest version all the time, they will not support certain CIs. It also creates unpredictability as you might assume a CI is not supported and then suddenly it gets supported and you didn't account for that. In addition, some of the manual detections are loose and might cause false-positives which could create hard-to-debug bugs.

Why does this even exist? It's just a few lines.

It's not about the number of lines, but rather discoverability and documentation. A lot of people wouldn't even know they need this. Feel free to copy-paste the code if you don't want the dependency. You might also want to read this blog post.

Keywords

FAQs

Last updated on 03 May 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc