Skip to content

Commit 952f5c0

Browse files
committed
added ability to pass node_args to forked process
1 parent a7e7ae4 commit 952f5c0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Requirements
1010

1111
The plug-in uses **Node.js** to run the TypeScript server. The plug-in looks for node in the PATH environment variable (which is inherited from Sublime).
1212

13-
If the `node_path` setting is present, this will override the PATH environment variable and the plug-in will use the value of the `node_path` setting as the node executable to run.
13+
If the `node_path` setting is present, this will override the PATH environment variable and the plug-in will use the value of the `node_path` setting as the node executable to run. Additionally, you can specify your own node arguments if the `node_args` setting is present. `node_args` _MUST_ be an array type where each array element is an argument to pass to the node executable.
1414
See more information in [our Tips and Known Issues](https://github.com/Microsoft/TypeScript-Sublime-Plugin/wiki/Tips-and-Known-Issues) wiki page.
1515

1616
Note: Using different versions of TypeScript

typescript/libs/node_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def __init__(self, script_path):
239239
# start node process
240240
pref_settings = sublime.load_settings('Preferences.sublime-settings')
241241
node_path = pref_settings.get('node_path')
242+
node_args = pref_settings.get('node_args', [])
242243
if node_path:
243244
print("Path of node executable is configured as: " + node_path)
244245
configured_node_path = os.path.expandvars(node_path)
@@ -260,17 +261,23 @@ def __init__(self, script_path):
260261
else:
261262
global_vars._node_path = node_path
262263
print("Trying to spawn node executable from: " + node_path)
264+
if node_args:
265+
print("Using node_args: " + str(node_args))
266+
process_args = [node_path] + node_args + [script_path, "--disableAutomaticTypingAcquisition"]
267+
else:
268+
process_args = [node_path, script_path, "--disableAutomaticTypingAcquisition"]
269+
263270
try:
264271
if os.name == "nt":
265272
# linux subprocess module does not have STARTUPINFO
266273
# so only use it if on Windows
267274
si = subprocess.STARTUPINFO()
268275
si.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW
269-
self.server_proc = subprocess.Popen([node_path, script_path, "--disableAutomaticTypingAcquisition"],
276+
self.server_proc = subprocess.Popen(process_args,
270277
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, startupinfo=si, bufsize=-1)
271278
else:
272279
log.debug("opening " + node_path + " " + script_path)
273-
self.server_proc = subprocess.Popen([node_path, script_path, "--disableAutomaticTypingAcquisition"],
280+
self.server_proc = subprocess.Popen(process_args,
274281
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, bufsize=-1)
275282
except:
276283
self.server_proc = None

0 commit comments

Comments
 (0)