@@ -7,6 +7,7 @@ async function runJsTransform(transformPath, args, extensions = DEFAULT_JS_EXTEN
77 const execa = require ( 'execa' ) ;
88 const chalk = require ( 'chalk' ) ;
99 const path = require ( 'path' ) ;
10+ const { Readable } = require ( 'stream' ) ;
1011 const { parseTransformArgs } = require ( './options-support' ) ;
1112
1213 let { paths, options, transformerOptions } = parseTransformArgs ( args ) ;
@@ -18,6 +19,7 @@ async function runJsTransform(transformPath, args, extensions = DEFAULT_JS_EXTEN
1819 } ) ;
1920
2021 let jscodeshiftPkg = require ( 'jscodeshift/package' ) ;
22+
2123 let jscodeshiftPath = path . dirname ( require . resolve ( 'jscodeshift/package' ) ) ;
2224 let binPath = path . join ( jscodeshiftPath , jscodeshiftPkg . bin . jscodeshift ) ;
2325
@@ -27,15 +29,25 @@ async function runJsTransform(transformPath, args, extensions = DEFAULT_JS_EXTEN
2729 '--extensions' ,
2830 extensions ,
2931 ...transformerOptions ,
30- ... foundPaths ,
32+ '--stdin' , // tell jscodeshift to read the list of files from stdin
3133 ] ;
3234
33- return execa ( binPath , binOptions , {
34- stdio : 'inherit' ,
35+ let handle = execa ( binPath , binOptions , {
36+ stdout : 'inherit' ,
37+ stderr : 'inherit' ,
38+ stdin : 'pipe' , // must be pipe for the below
3539 env : {
3640 CODEMOD_CLI_ARGS : JSON . stringify ( options ) ,
3741 } ,
3842 } ) ;
43+
44+ // https://github.com/ember-codemods/es5-getter-ember-codemod/issues/34
45+ let pathsStream = new Readable ( ) ;
46+ pathsStream . push ( foundPaths . join ( '\n' ) ) ;
47+ pathsStream . push ( null ) ;
48+ pathsStream . pipe ( handle . stdin ) ;
49+
50+ return await handle ;
3951 } catch ( error ) {
4052 console . error ( chalk . red ( error . stack ) ) ; // eslint-disable-line no-console
4153 process . exitCode = 1 ;
0 commit comments