Skip to content

Commit 13a24ce

Browse files
author
khoden
committed
nots/cli: Убрать выхлоп pnpm из nots test (показывать только при --verbose)
commit_hash:53763489b6fe45c4add50d476dd1029b39717072
1 parent 151c2dd commit 13a24ce

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

build/plugins/lib/nots/package_manager/base/package_manager.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .constants import NPM_REGISTRY_URL
77
from .package_json import PackageJson
88
from .utils import build_nm_path, build_pj_path
9-
from .timeit import timeit, is_timeit_enabled
9+
from .timeit import timeit
1010

1111

1212
class PackageManagerError(RuntimeError):
@@ -34,6 +34,7 @@ def __init__(
3434
script_path,
3535
module_path=None,
3636
sources_root=None,
37+
verbose=False,
3738
):
3839
self.module_path = build_path[len(build_root) + 1 :] if module_path is None else module_path
3940
self.build_path = build_path
@@ -42,6 +43,7 @@ def __init__(
4243
self.sources_root = sources_path[: -len(self.module_path) - 1] if sources_root is None else sources_root
4344
self.nodejs_bin_path = nodejs_bin_path
4445
self.script_path = script_path
46+
self.verbose = verbose
4547

4648
@classmethod
4749
def load_package_json(cls, path):
@@ -133,18 +135,27 @@ def _exec_command(self, args, cwd: str, include_defaults=True, script_path=None,
133135
+ args
134136
+ (self._get_default_options() if include_defaults else [])
135137
)
136-
p = subprocess.Popen(cmd, cwd=cwd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
138+
p = subprocess.Popen(
139+
cmd,
140+
cwd=cwd,
141+
stdin=None,
142+
stdout=subprocess.PIPE,
143+
stderr=subprocess.PIPE,
144+
env=env,
145+
text=True,
146+
encoding="utf-8",
147+
)
137148
stdout, stderr = p.communicate()
138149

139-
if is_timeit_enabled():
150+
if self.verbose:
140151
print(f'cd {cwd} && {" ".join(cmd)}', file=sys.stderr)
141-
print(f'stdout: {stdout.decode("utf-8")}', file=sys.stderr)
142-
print(f'stderr: {stderr.decode("utf-8")}', file=sys.stderr)
152+
print(f'stdout: {stdout}', file=sys.stderr) if stdout else None
153+
print(f'stderr: {stderr}', file=sys.stderr) if stderr else None
143154

144155
if p.returncode != 0:
145156
self._dump_debug_log()
146157

147-
raise PackageManagerCommandError(cmd, p.returncode, stdout.decode("utf-8"), stderr.decode("utf-8"))
158+
raise PackageManagerCommandError(cmd, p.returncode, stdout, stderr)
148159

149160
def _nm_path(self, *parts):
150161
return os.path.join(build_nm_path(self.build_path), *parts)

build/plugins/lib/nots/package_manager/base/timeit.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,3 @@ def timeit(func):
2727
return logging.timeit(func)
2828
else:
2929
return func
30-
31-
32-
def is_timeit_enabled():
33-
logging = import_optional_module("devtools.frontend_build_platform.libraries.logging")
34-
if logging:
35-
return logging.timeit_options.enabled
36-
else:
37-
return False

0 commit comments

Comments
 (0)