1
1
import subprocess
2
- import sys , imp , codecs
2
+ import sys , imp , codecs , shlex
3
3
import node_variables
4
4
5
5
class NodeJS (object ):
@@ -8,7 +8,14 @@ def eval(self, js, eval_type="eval", strict_mode=False):
8
8
js = ("'use strict'; " if strict_mode else "" ) + js
9
9
eval_type = "--eval" if eval_type == "eval" else "--print"
10
10
11
- p = subprocess .Popen ([node_variables .NODE_JS_PATH_EXECUTABLE , eval_type , js ], shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
11
+ args = ""
12
+
13
+ if node_variables .NODE_JS_OS == 'win' :
14
+ args = [node_variables .NODE_JS_PATH_EXECUTABLE , eval_type , js ]
15
+ else :
16
+ args = shlex .quote (node_variables .NODE_JS_PATH_EXECUTABLE )+ " " + shlex .quote (eval_type )+ " " + shlex .quote (js )
17
+
18
+ p = subprocess .Popen (args , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
12
19
lines = ""
13
20
14
21
# check for errors
@@ -28,7 +35,14 @@ def eval(self, js, eval_type="eval", strict_mode=False):
28
35
29
36
def getCurrentNodeJSVersion (self ) :
30
37
31
- p = subprocess .Popen ([node_variables .NODE_JS_PATH_EXECUTABLE , '-v' ], shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
38
+ args = ""
39
+
40
+ if node_variables .NODE_JS_OS == 'win' :
41
+ args = [node_variables .NODE_JS_PATH_EXECUTABLE , "-v" ]
42
+ else :
43
+ args = shlex .quote (node_variables .NODE_JS_PATH_EXECUTABLE )+ " -v"
44
+
45
+ p = subprocess .Popen (args , shell = True , stdout = subprocess .PIPE , stderr = subprocess .PIPE )
32
46
lines = ""
33
47
34
48
# check for errors
0 commit comments