11'use strict' ;
22
3- function runTransform ( binRoot , transformName , args ) {
3+ async function runTransform ( binRoot , transformName , args ) {
44 const globby = require ( 'globby' ) ;
55 const execa = require ( 'execa' ) ;
66 const chalk = require ( 'chalk' ) ;
@@ -9,27 +9,26 @@ function runTransform(binRoot, transformName, args) {
99
1010 let { paths, options } = parseTransformArgs ( args ) ;
1111
12- return globby ( paths )
13- . then ( paths => {
14- let transformPath = path . join ( binRoot , '..' , 'transforms' , transformName , 'index.js' ) ;
12+ try {
13+ let foundPaths = await globby ( paths ) ;
14+ let transformPath = path . join ( binRoot , '..' , 'transforms' , transformName , 'index.js' ) ;
1515
16- let jscodeshiftPkg = require ( 'jscodeshift/package' ) ;
17- let jscodeshiftPath = path . dirname ( require . resolve ( 'jscodeshift/package' ) ) ;
18- let binPath = path . join ( jscodeshiftPath , jscodeshiftPkg . bin . jscodeshift ) ;
16+ let jscodeshiftPkg = require ( 'jscodeshift/package' ) ;
17+ let jscodeshiftPath = path . dirname ( require . resolve ( 'jscodeshift/package' ) ) ;
18+ let binPath = path . join ( jscodeshiftPath , jscodeshiftPkg . bin . jscodeshift ) ;
1919
20- return execa ( binPath , [ '-t' , transformPath , '--extensions' , 'js,ts' , ...paths ] , {
21- stdio : 'inherit' ,
22- env : {
23- CODEMOD_CLI_ARGS : JSON . stringify ( options ) ,
24- } ,
25- } ) ;
26- } )
27- . catch ( error => {
28- console . error ( chalk . red ( error . stack ) ) ; // eslint-disable-line no-console
29- process . exitCode = 1 ;
30-
31- throw error ;
20+ return execa ( binPath , [ '-t' , transformPath , '--extensions' , 'js,ts' , ...foundPaths ] , {
21+ stdio : 'inherit' ,
22+ env : {
23+ CODEMOD_CLI_ARGS : JSON . stringify ( options ) ,
24+ } ,
3225 } ) ;
26+ } catch ( error ) {
27+ console . error ( chalk . red ( error . stack ) ) ; // eslint-disable-line no-console
28+ process . exitCode = 1 ;
29+
30+ throw error ;
31+ }
3332}
3433
3534module . exports = {
0 commit comments