Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaël Nison <nison.mael@gmail.com>2020-09-28 18:35:09 +0300
committerJames M Snell <jasnell@gmail.com>2021-08-25 17:55:32 +0300
commit46598b88bfaecbad92492b03758c3dcc69d5e4d0 (patch)
treeac3ed059af38f63d22e9242dca6596a71d97af87 /tools/install.py
parentf581f6da94d011684661d48c9557d5aaf0d13c19 (diff)
deps: add corepack
Corepack provides shims for Yarn and pnpm in order to soften the developer experience when working on Node projects. Refs: https://github.com/nodejs/node/issues/15244 Refs: https://github.com/nodejs/TSC/issues/904 PR-URL: https://github.com/nodejs/node/pull/39608 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'tools/install.py')
-rwxr-xr-xtools/install.py57
1 files changed, 34 insertions, 23 deletions
diff --git a/tools/install.py b/tools/install.py
index 24cf51e7319..41cc1cbc60a 100755
--- a/tools/install.py
+++ b/tools/install.py
@@ -79,8 +79,8 @@ def uninstall(paths, dst):
for path in paths:
try_remove(path, dst)
-def npm_files(action):
- target_path = 'lib/node_modules/npm/'
+def package_files(action, name, bins):
+ target_path = 'lib/node_modules/' + name + '/'
# don't install npm if the target path is a symlink, it probably means
# that a dev version of npm is installed there
@@ -88,28 +88,37 @@ def npm_files(action):
# npm has a *lot* of files and it'd be a pain to maintain a fixed list here
# so we walk its source directory instead...
- for dirname, subdirs, basenames in os.walk('deps/npm', topdown=True):
+ root = 'deps/' + name
+ for dirname, subdirs, basenames in os.walk(root, topdown=True):
subdirs[:] = [subdir for subdir in subdirs if subdir != 'test']
paths = [os.path.join(dirname, basename) for basename in basenames]
- action(paths, target_path + dirname[9:] + '/')
-
- # create/remove symlink
- link_path = abspath(install_path, 'bin/npm')
- if action == uninstall:
- action([link_path], 'bin/npm')
- elif action == install:
- try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path)
- else:
- assert 0 # unhandled action type
-
- # create/remove symlink
- link_path = abspath(install_path, 'bin/npx')
- if action == uninstall:
- action([link_path], 'bin/npx')
- elif action == install:
- try_symlink('../lib/node_modules/npm/bin/npx-cli.js', link_path)
- else:
- assert 0 # unhandled action type
+ action(paths, target_path + dirname[len(root) + 1:] + '/')
+
+ # create/remove symlinks
+ for bin_name, bin_target in bins.items():
+ link_path = abspath(install_path, 'bin/' + bin_name)
+ if action == uninstall:
+ action([link_path], 'bin/' + bin_name)
+ elif action == install:
+ try_symlink('../lib/node_modules/' + name + '/' + bin_target, link_path)
+ else:
+ assert 0 # unhandled action type
+
+def npm_files(action):
+ package_files(action, 'npm', {
+ 'npm': 'bin/npm-cli.js',
+ 'npx': 'bin/npx-cli.js',
+ })
+
+def corepack_files(action):
+ package_files(action, 'corepack', {
+ 'corepack': 'dist/corepack.js',
+# Not the default just yet:
+# 'yarn': 'dist/yarn.js',
+# 'yarnpkg': 'dist/yarn.js',
+# 'pnpm': 'dist/pnpm.js',
+# 'pnpx': 'dist/pnpx.js',
+ })
def subdir_files(path, dest, action):
ret = {}
@@ -152,7 +161,9 @@ def files(action):
else:
action(['doc/node.1'], 'share/man/man1/')
- if 'true' == variables.get('node_install_npm'): npm_files(action)
+ if 'true' == variables.get('node_install_npm'):
+ npm_files(action)
+ corepack_files(action)
headers(action)