Skip to content

Commit 873d747

Browse files
Update main.py
fix issue after commit b4ffaab
1 parent b4ffaab commit 873d747

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

node/main.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import subprocess
2-
import sys, imp, codecs
2+
import sys, imp, codecs, shlex
33
import node_variables
44

55
class NodeJS(object):
@@ -8,7 +8,14 @@ def eval(self, js, eval_type="eval", strict_mode=False):
88
js = ("'use strict'; " if strict_mode else "") + js
99
eval_type = "--eval" if eval_type == "eval" else "--print"
1010

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)
1219
lines = ""
1320

1421
# check for errors
@@ -28,7 +35,14 @@ def eval(self, js, eval_type="eval", strict_mode=False):
2835

2936
def getCurrentNodeJSVersion(self) :
3037

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)
3246
lines = ""
3347

3448
# check for errors

0 commit comments

Comments
 (0)