diff options
author | Bert Belder <bertbelder@gmail.com> | 2018-06-12 22:05:49 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2018-06-13 00:31:38 +0200 |
commit | 1676822888ef6c75bb2afff3b7a93d030d63f2ea (patch) | |
tree | 5a785a6af7713f0fc44d5c9a02062dfc046f09fa /deno2/js/run_node.py | |
parent | 36f657c0d2961a8a798b0f209ff40aabd169b766 (diff) |
deno2: build on Windows
Diffstat (limited to 'deno2/js/run_node.py')
-rwxr-xr-x | deno2/js/run_node.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/deno2/js/run_node.py b/deno2/js/run_node.py index 1a1dc5cc7..8f650a534 100755 --- a/deno2/js/run_node.py +++ b/deno2/js/run_node.py @@ -6,13 +6,26 @@ import subprocess import sys import os +def symlink(target, name, target_is_dir=False): + if os.name == "nt": + from ctypes import windll, WinError + CreateSymbolicLinkW = windll.kernel32.CreateSymbolicLinkW + 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() + else: + os.symlink(target, name) js_path = os.path.dirname(os.path.realpath(__file__)) node_modules_path = os.path.join(js_path, "node_modules") # root_out_dir if not os.path.exists("node_modules"): - os.symlink(node_modules_path, "node_modules") + symlink(node_modules_path, "node_modules", True) args = ["node"] + sys.argv[1:] sys.exit(subprocess.call(args)) |