diff options
author | vturov <vturov@yandex-team.com> | 2024-03-29 18:29:15 +0300 |
---|---|---|
committer | vturov <vturov@yandex-team.com> | 2024-03-29 18:40:32 +0300 |
commit | cc0d0419d1785b914832d68319402a1bab2aebaf (patch) | |
tree | ec900f16dd7240b1e369b084566937d7e999cd75 | |
parent | f39261a434c46274b5eaef0927ee3b2e0d95b41a (diff) | |
download | ydb-cc0d0419d1785b914832d68319402a1bab2aebaf.tar.gz |
PR from branch users/vturov/feat/speed-up-node-modules
использовать tar при распаковке node_modules
Возможность линтить синтетический проект с зависимостями
dab4dcfbd7c366508c07a59f14c2be77bafdc935
-rw-r--r-- | build/plugins/lib/nots/package_manager/base/node_modules_bundler.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/build/plugins/lib/nots/package_manager/base/node_modules_bundler.py b/build/plugins/lib/nots/package_manager/base/node_modules_bundler.py index aae54c0be6..c632ecb24a 100644 --- a/build/plugins/lib/nots/package_manager/base/node_modules_bundler.py +++ b/build/plugins/lib/nots/package_manager/base/node_modules_bundler.py @@ -1,4 +1,6 @@ import os +import sys +import subprocess import tarfile from io import BytesIO @@ -53,8 +55,16 @@ def extract_node_modules(build_root, node_modules_path, bundle_path): :param bundle_path: tarball path :type bundle_path: str """ - with tarfile.open(bundle_path) as tf: - tf.extractall(node_modules_path) + os.makedirs(node_modules_path, exist_ok=True) + tar_unpack_cmd = ["tar", "xf", bundle_path, "-C", node_modules_path] + p = subprocess.run(tar_unpack_cmd, capture_output=True, text=True) + if p.returncode != 0: + if p.stdout: + sys.stderr.write(f"stdout:\n{p.stdout}\n") + if p.stderr: + sys.stderr.write(f"stderr:\n{p.stderr}\n") + + return False with open(os.path.join(node_modules_path, PEERS_DIR, PEERS_INDEX)) as peers_file: peers = peers_file.read().split("\n") @@ -64,3 +74,5 @@ def extract_node_modules(build_root, node_modules_path, bundle_path): bundled_nm_path = build_nm_path(os.path.join(node_modules_path, PEERS_DIR, p)) nm_path = build_nm_path(os.path.join(build_root, p)) os.rename(bundled_nm_path, nm_path) + + return True |