
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
is-interactive
Advanced tools
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.
$ npm install is-interactive
import isInteractive from 'is-interactive';
isInteractive();
//=> true
Type: object
Type: stream.Writable
Default: process.stdout
The stream to check.
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.
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.
While not identical in functionality, supports-color is a package that can be used alongside is-interactive to further enhance CLI applications. It checks if the terminal supports color, which, combined with interactivity checks, can help tailor output to suit the capabilities of the user's terminal. Unlike is-interactive, which focuses solely on detecting interactivity, supports-color provides insights into the terminal's color capabilities.
Inquirer.js is a comprehensive library for creating interactive CLI prompts. Although it serves a different primary purpose compared to is-interactive, it's relevant in the context of building interactive CLI applications. Inquirer assumes an interactive environment to present and handle user prompts, whereas is-interactive could be used to determine whether it's appropriate to use Inquirer or a more straightforward, non-interactive input method.
FAQs
Check if stdout or stderr is interactive
The npm package is-interactive receives a total of 24,656,438 weekly downloads. As such, is-interactive popularity was classified as popular.
We found that is-interactive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.