Socket
Book a DemoInstallSign in
Socket

force-stdin-tty

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

force-stdin-tty

Force stdin to be assigned to /dev/tty

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

force-stdin-tty

Force stdin to be assigned to /dev/tty

Install

Using npm:

npm install --save-dev force-stdin-tty

or using yarn:

yarn add force-stdin-tty --dev

Usage

This package can be used to force git hooks to allow prompts for user input. If the user is using a UI and not a terminal, you can tell them to use a terminal. See this stackoverflow question.

import { forceStdinTty } from 'force-stdin-tty';

let overwroteStdin = false;
try {
  overwroteStdin = forceStdinTty();
} catch {
  console.error('Please push your code in a terminal.');
  process.exit(1);
}

if (overwroteStdin) {
  process.stdin.destroy();
}

husky support

This package works with husky.

husky initially did add support for stdin, but later removed it due to a Windows bug:

husky changelog

husky getScript.ts

husky current code

The husky author suggests using the undocumented ~/.huskyrc to enable prompts for git hooks. But it isn't ideal because each developer would have to enable it.

See:

husky#442

husky#385

TypeScript support

This package supports TypeScript.

Keywords

git

FAQs

Package last updated on 27 Jul 2019

Did you know?

Socket

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