summaryrefslogtreecommitdiff
path: root/src/js/run_node.py
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-06-22 21:16:27 +0200
committerRyan Dahl <ry@tinyclouds.org>2018-06-22 23:19:55 +0200
commit9315adb8c58099f892a8c44e489a62b4e56e376d (patch)
treea09d9a505432494b9622a4695df6a64f6a7a20e3 /src/js/run_node.py
parent6f51c1774d3d1120a5bab8b5637a30437b324cf5 (diff)
lint
Diffstat (limited to 'src/js/run_node.py')
-rwxr-xr-xsrc/js/run_node.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/js/run_node.py b/src/js/run_node.py
index 3125bfc2f..bdf132ae5 100755
--- a/src/js/run_node.py
+++ b/src/js/run_node.py
@@ -8,30 +8,31 @@ import subprocess
import sys
import os
+
def symlink(target, name, target_is_dir=False):
- if os.name == "nt":
- import ctypes
- CreateSymbolicLinkW = ctypes.windll.kernel32.CreateSymbolicLinkW
- CreateSymbolicLinkW.restype = ctypes.c_ubyte
- CreateSymbolicLinkW.argtypes = (ctypes.c_wchar_p,
- ctypes.c_wchar_p,
- ctypes.c_uint32)
+ if os.name == "nt":
+ import ctypes
+ CreateSymbolicLinkW = ctypes.windll.kernel32.CreateSymbolicLinkW
+ CreateSymbolicLinkW.restype = ctypes.c_ubyte
+ CreateSymbolicLinkW.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p,
+ ctypes.c_uint32)
+
+ flags = 0x02 # SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
+ if (target_is_dir):
+ flags |= 0x01 # SYMBOLIC_LINK_FLAG_DIRECTORY
+ if not CreateSymbolicLinkW(name, target, flags):
+ raise ctypes.WinError()
+ else:
+ os.symlink(target, name)
- flags = 0x02 # SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
- if (target_is_dir):
- flags |= 0x01 # SYMBOLIC_LINK_FLAG_DIRECTORY
- if not CreateSymbolicLinkW(name, target, flags):
- raise ctypes.WinError()
- else:
- os.symlink(target, name)
js_path = os.path.dirname(os.path.realpath(__file__))
node_modules_path = os.path.join(js_path, "node_modules")
if not os.path.lexists("node_modules"):
- if os.path.exists("node_modules"):
- os.unlink("node_modules")
- symlink(node_modules_path, "node_modules", True)
+ if os.path.exists("node_modules"):
+ os.unlink("node_modules")
+ symlink(node_modules_path, "node_modules", True)
args = ["node"] + sys.argv[1:]
sys.exit(subprocess.call(args))