@@ -44,6 +44,21 @@ const parseArgv = () => (
44
44
}
45
45
) ;
46
46
47
+ /**
48
+ * will pipe stdio as if we were running the command ourselves!
49
+ *
50
+ * see https://stackoverflow.com/a/47338488/9285308
51
+ *
52
+ * usage:
53
+ *
54
+ * ```js
55
+ * const command = "ls -la";
56
+ * require("child_process").execSync(command, { ...pipeStdioOpts() });
57
+ * ```
58
+ *
59
+ */
60
+ const pipeStdioOpts = ( cwd = process . cwd ( ) ) => ( { cwd, stdio : 'inherit' } ) ;
61
+
47
62
run ( ) ;
48
63
49
64
function run ( ) {
@@ -65,7 +80,7 @@ function run() {
65
80
const dir = path . dirname ( t ) ;
66
81
const cmd = `yarn --cwd ${ dir } build` ;
67
82
console . log ( 'transform to run, build cmd' , { cmd } ) ;
68
- cp . execSync ( cmd ) ;
83
+ cp . execSync ( cmd , { ... pipeStdioOpts ( ) } ) ;
69
84
return t ;
70
85
}
71
86
} )
@@ -77,17 +92,7 @@ function run() {
77
92
const cmdToExec = `${ cliPath } --parser ${ parser } -e ${ extensions } -t ${ transformsToRun } ${ fileOrDirectoryToModify } ` ;
78
93
console . log ( { cmdToExec } ) ;
79
94
80
- cp . exec ( cmdToExec , ( err , stdout , stderr ) => {
81
- if ( err ) {
82
- console . error ( stderr ) ;
83
- return process . exit ( 1 ) ;
84
- }
85
-
86
- console . log ( stdout ) ;
87
-
88
- console . log ( 'succ' ) ;
89
- process . exit ( 0 ) ;
90
- } ) ;
95
+ cp . execSync ( cmdToExec , { ...pipeStdioOpts ( ) } ) ;
91
96
}
92
97
93
98
function parseArrayFromCsv ( csv = '' ) {
@@ -99,7 +104,7 @@ function parseArrayFromCsv(csv = '') {
99
104
}
100
105
101
106
function resolveTransformsFromShorthand ( [ pathToCodemodPkg , transformVersion ] ) {
102
- cp . execSync ( `yarn --cwd ${ pathToCodemodPkg } build` ) ;
107
+ cp . execSync ( `yarn --cwd ${ pathToCodemodPkg } build` , { ... pipeStdioOpts ( ) } ) ;
103
108
console . log ( 'built' ) ;
104
109
105
110
const pathToCodemodConfig = path . join (
0 commit comments