File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,15 @@ process.once("uncaughtException", err => {
56
56
} ) ;
57
57
58
58
if ( useStdIn ) {
59
- process . exitCode = cli . execute ( process . argv , fs . readFileSync ( process . stdin . fd , "utf8" ) ) ;
59
+
60
+ /*
61
+ * Note: `process.stdin.fd` is not used here due to https://github.com/nodejs/node/issues/7439.
62
+ * Accessing the `process.stdin` property seems to modify the behavior of file descriptor 0, resulting
63
+ * in an error when stdin is piped in asynchronously.
64
+ */
65
+ const STDIN_FILE_DESCRIPTOR = 0 ;
66
+
67
+ process . exitCode = cli . execute ( process . argv , fs . readFileSync ( STDIN_FILE_DESCRIPTOR , "utf8" ) ) ;
60
68
} else if ( init ) {
61
69
const configInit = require ( "../lib/config/config-initializer" ) ;
62
70
Original file line number Diff line number Diff line change @@ -152,6 +152,17 @@ describe("bin/eslint.js", () => {
152
152
}
153
153
) ;
154
154
155
+ it ( "successfully reads from an asynchronous pipe" , ( ) => {
156
+ const child = runESLint ( [ "--stdin" , "--no-eslintrc" ] ) ;
157
+
158
+ child . stdin . write ( "var foo = bar;\n" ) ;
159
+ return new Promise ( resolve => setTimeout ( resolve , 300 ) ) . then ( ( ) => {
160
+ child . stdin . write ( "var baz = qux;\n" ) ;
161
+ child . stdin . end ( ) ;
162
+
163
+ return assertExitCode ( child , 0 ) ;
164
+ } ) ;
165
+ } ) ;
155
166
} ) ;
156
167
157
168
describe ( "running on files" , ( ) => {
You can’t perform that action at this time.
0 commit comments