File tree Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Expand file tree Collapse file tree 2 files changed +35
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
"use strict" ;
4
4
5
- var nodeCLI = require ( "shelljs-nodecli" ) ;
5
+ var execSync = require ( "child_process" ) . execSync ;
6
+ var objectAssign = require ( "object-assign" ) ;
7
+ var path = require ( "path" ) ;
6
8
7
9
var argv = process . argv . slice ( 2 ) ;
8
10
var args = argv . slice ( 1 ) ;
9
11
var transform = argv [ 0 ] ;
10
12
11
- nodeCLI . exec (
13
+ /**
14
+ * Add possible node_modules/.bin paths to env and run the command passed in.
15
+ *
16
+ * @param {string } cmd The command to run
17
+ * @returns {void }
18
+ */
19
+ function execWithNodeModules ( cmd ) {
20
+ var SEPARATOR = process . platform === "win32" ? ";" : ":" ,
21
+ env = objectAssign ( { } , process . env ) ;
22
+
23
+ env . PATH = [
24
+ // Covers case when npm flattens dependencies and the jscodeshift bin will be directly under the root
25
+ // node_modules folder
26
+ path . resolve ( "./node_modules/.bin" ) ,
27
+ // Covers case when dependencies are not flattened and the jscodeshift bin can be found under the
28
+ // node_modules folder of our package
29
+ path . resolve ( __dirname , "../node_modules/.bin" ) ,
30
+ env . PATH
31
+ ] . join ( SEPARATOR ) ;
32
+
33
+ execSync ( cmd , {
34
+ env : env ,
35
+ cwd : process . cwd ( ) ,
36
+ stdio : "inherit"
37
+ } ) ;
38
+ }
39
+
40
+ execWithNodeModules ( [
12
41
"jscodeshift" ,
13
- "-t" , "./lib/" + transform + "/" + transform + ".js" ,
42
+ "-t" ,
43
+ path . resolve ( __dirname , "../lib/" + transform + "/" + transform + ".js" ) ,
14
44
args . join ( " " )
15
- ) ;
45
+ ] . join ( " " ) ) ;
Original file line number Diff line number Diff line change 32
32
},
33
33
"dependencies" : {
34
34
"jscodeshift" : " ^0.3.20" ,
35
- "shelljs-nodecli " : " ^0 .1.1 "
35
+ "object-assign " : " ^4 .1.0 "
36
36
},
37
37
"keywords" : [
38
38
" javascript" ,
You can’t perform that action at this time.
0 commit comments