Skip to content

Commit 0a4bc06

Browse files
committed
added ability to pass node_args to forked process
1 parent 56d9be0 commit 0a4bc06

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
@@ -240,6 +240,7 @@ def __init__(self, script_path):
240240
# start node process
241241
pref_settings = sublime.load_settings('Preferences.sublime-settings')
242242
node_path = pref_settings.get('node_path')
243+
node_args = pref_settings.get('node_args', [])
243244
if node_path:
244245
print("Path of node executable is configured as: " + node_path)
245246
configured_node_path = os.path.expandvars(node_path)
@@ -261,17 +262,23 @@ def __init__(self, script_path):
261262
else:
262263
global_vars._node_path = node_path
263264
print("Trying to spawn node executable from: " + node_path)
265+
if node_args:
266+
print("Using node_args: " + str(node_args))
267+
process_args = [node_path] + node_args + [script_path, "--disableAutomaticTypingAcquisition"]
268+
else:
269+
process_args = [node_path, script_path, "--disableAutomaticTypingAcquisition"]
270+
264271
try:
265272
if os.name == "nt":
266273
# linux subprocess module does not have STARTUPINFO
267274
# so only use it if on Windows
268275
si = subprocess.STARTUPINFO()
269276
si.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW
270-
self.server_proc = subprocess.Popen([node_path, script_path, "--disableAutomaticTypingAcquisition"],
277+
self.server_proc = subprocess.Popen(process_args,
271278
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, startupinfo=si, bufsize=-1)
272279
else:
273280
log.debug("opening " + node_path + " " + script_path)
274-
self.server_proc = subprocess.Popen([node_path, script_path, "--disableAutomaticTypingAcquisition"],
281+
self.server_proc = subprocess.Popen(process_args,
275282
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, bufsize=-1)
276283
except:
277284
self.server_proc = None

0 commit comments

Comments
 (0)