55 lines
2.1 KiB
Diff
55 lines
2.1 KiB
Diff
From 94d3d4f85a245f474091a5e241e249ecbc2c12a1 Mon Sep 17 00:00:00 2001
|
|
From: Alexey Pavlov <alexpux@gmail.com>
|
|
Date: Thu, 12 Apr 2018 10:20:30 +0200
|
|
Subject: [PATCH 12/23] Use shell wrapper script for npm on MSYS2 mingw-w64
|
|
|
|
---
|
|
tools/install.py | 24 ++++++++++++++++++++++--
|
|
1 file changed, 22 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/tools/install.py b/tools/install.py
|
|
index be2bab54..20dfee30 100755
|
|
--- a/tools/install.py
|
|
+++ b/tools/install.py
|
|
@@ -101,7 +101,17 @@
|
|
if action == uninstall:
|
|
action([link_path], 'bin/' + bin_name)
|
|
elif action == install:
|
|
- try_symlink('../lib/node_modules/' + name + '/' + bin_target, link_path)
|
|
+ # Use MSYS2 shell script wrapper.
|
|
+ if ((os.name == 'nt' and 'GCC' in sys.version) or
|
|
+ (os.name == 'posix' and 'NT' in platform.system())):
|
|
+ # Copy the wrapper shell script
|
|
+ try_copy('deps/npm/bin/npm', link_path)
|
|
+ # deps/npm/bin/npm is a shell script so the shebang must run sh, not node
|
|
+ s = open(link_path, 'r').read()
|
|
+ s = re.sub(r'#!.*\n', '#!' + '/usr/bin/env sh' + '\n', s)
|
|
+ open(link_path, 'w').write(s)
|
|
+ else:
|
|
+ try_symlink('../lib/node_modules/' + name + '/' + bin_target, link_path)
|
|
else:
|
|
assert 0 # unhandled action type
|
|
|
|
@@ -128,7 +138,17 @@
|
|
if action == uninstall:
|
|
action([link_path], 'bin/node-gyp')
|
|
elif action == install:
|
|
- try_symlink('../lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js', link_path)
|
|
+ # Use MSYS2 shell script wrapper.
|
|
+ if ((os.name == 'nt' and 'GCC' in sys.version) or
|
|
+ (os.name == 'posix' and 'NT' in platform.system())):
|
|
+ # Copy the wrapper shell script
|
|
+ try_copy('deps/npm/bin/npm', link_path)
|
|
+ # deps/npm/bin/npm is a shell script so the shebang must run sh, not node
|
|
+ s = open(link_path, 'r').read()
|
|
+ s = re.sub(r'#!.*\n', '#!' + '/usr/bin/env sh' + '\n', s)
|
|
+ open(link_path, 'w').write(s)
|
|
+ else:
|
|
+ try_symlink('../lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js', link_path)
|
|
else:
|
|
assert 0 # unhandled action type
|
|
|
|
--
|
|
2.17.0.windows.1
|
|
|