Skip to content

Commit 19976ee

Browse files
rramphalremy
authored andcommitted
fix: added defensive check against process.stdin (#5)
Instead of assuming that `process.stdin` will return an object, add a check to make sure that it does before trying to access `process.stdin.isTTY`.
1 parent 0097d0c commit 19976ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ if (typeof module !== 'undefined') {
220220
module.exports.afterLine = afterLine;
221221
if (!module.parent) {
222222
// cli mode
223-
if (!process.stdin.isTTY) {
223+
if (process.stdin && !process.stdin.isTTY) {
224224
const stdinBuffer = require('fs').readFileSync(0); // STDIN_FILENO = 0
225225
console.log(module.exports(JSON.parse(stdinBuffer.toString())));
226226
}

0 commit comments

Comments
 (0)