diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2018-06-22 17:50:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-22 17:50:27 +0200 |
commit | bd4693471f5a09af7b360bc8cf05e52ed89455d3 (patch) | |
tree | 75e8b72dbb7c58f75e071108412cf057ff0d41e6 | |
parent | 3b595253a2e9f8badc416f85d0b09bf48f344634 (diff) |
run_node.py don't error if symlink exists (#279)
The switch from deno2/ to src/ made Travis's cached symlink invalid and
now os.path.exists() returns false.
-rwxr-xr-x | src/js/run_node.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/js/run_node.py b/src/js/run_node.py index 1a69dc502..3125bfc2f 100755 --- a/src/js/run_node.py +++ b/src/js/run_node.py @@ -10,22 +10,27 @@ import os def symlink(target, name, target_is_dir=False): if os.name == "nt": - from ctypes import windll, WinError - CreateSymbolicLinkW = windll.kernel32.CreateSymbolicLinkW + 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.encode('utf-16le'), - target.encode('utf-16le'), - flags): - raise WinError() + 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.exists("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) args = ["node"] + sys.argv[1:] |