@@ -7,6 +7,7 @@ async function runJsTransform(transformPath, args, extensions = DEFAULT_JS_EXTEN
7
7
const execa = require ( 'execa' ) ;
8
8
const chalk = require ( 'chalk' ) ;
9
9
const path = require ( 'path' ) ;
10
+ const { Readable } = require ( 'stream' ) ;
10
11
const { parseTransformArgs } = require ( './options-support' ) ;
11
12
12
13
let { paths, options, transformerOptions } = parseTransformArgs ( args ) ;
@@ -18,6 +19,7 @@ async function runJsTransform(transformPath, args, extensions = DEFAULT_JS_EXTEN
18
19
} ) ;
19
20
20
21
let jscodeshiftPkg = require ( 'jscodeshift/package' ) ;
22
+
21
23
let jscodeshiftPath = path . dirname ( require . resolve ( 'jscodeshift/package' ) ) ;
22
24
let binPath = path . join ( jscodeshiftPath , jscodeshiftPkg . bin . jscodeshift ) ;
23
25
@@ -27,15 +29,25 @@ async function runJsTransform(transformPath, args, extensions = DEFAULT_JS_EXTEN
27
29
'--extensions' ,
28
30
extensions ,
29
31
...transformerOptions ,
30
- ... foundPaths ,
32
+ '--stdin' , // tell jscodeshift to read the list of files from stdin
31
33
] ;
32
34
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
35
39
env : {
36
40
CODEMOD_CLI_ARGS : JSON . stringify ( options ) ,
37
41
} ,
38
42
} ) ;
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 ;
39
51
} catch ( error ) {
40
52
console . error ( chalk . red ( error . stack ) ) ; // eslint-disable-line no-console
41
53
process . exitCode = 1 ;
0 commit comments