Package Exports
- force-stdin-tty
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (force-stdin-tty) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
force-stdin-tty
Force stdin to be assigned to /dev/tty
Install
Using npm:
npm install --save-dev force-stdin-ttyor using yarn:
yarn add force-stdin-tty --devUsage
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:
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:
TypeScript support
This package supports TypeScript.