File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -227,7 +227,8 @@ export function main (argv: string[]) {
227
227
Module . runMain ( )
228
228
} else {
229
229
// Piping of execution _only_ occurs when no other script is specified.
230
- if ( process . stdin . isTTY ) {
230
+ // --interactive flag forces REPL
231
+ if ( interactive || process . stdin . isTTY ) {
231
232
startRepl ( service , state , code )
232
233
} else {
233
234
let buffer = code || ''
Original file line number Diff line number Diff line change @@ -260,6 +260,21 @@ describe('ts-node', function () {
260
260
cp . stdin ! . end ( 'true' )
261
261
} )
262
262
263
+ it ( 'should run REPL when --interactive passed and stdin is not a TTY' , function ( done ) {
264
+ const cp = exec ( `${ cmd } --interactive` , function ( err , stdout ) {
265
+ expect ( err ) . to . equal ( null )
266
+ expect ( stdout ) . to . equal (
267
+ '> 123\n' +
268
+ 'undefined\n' +
269
+ '> '
270
+ )
271
+ return done ( )
272
+ } )
273
+
274
+ cp . stdin ! . end ( 'console.log("123")\n' )
275
+
276
+ } )
277
+
263
278
it ( 'should support require flags' , function ( done ) {
264
279
exec ( `${ cmd } -r ./tests/hello-world -pe "console.log('success')"` , function ( err , stdout ) {
265
280
expect ( err ) . to . equal ( null )
You can’t perform that action at this time.
0 commit comments