From f94df4c92c439bba60ecfaa9ee2e055d354f58a6 Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Fri, 8 Aug 2025 13:27:32 +0300 Subject: [PATCH 1/2] Improve gn npm failure log Signed-off-by: Anton Tarasov --- gn/command/npm_util.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/gn/command/npm_util.py b/gn/command/npm_util.py index faa6e5bb7d..e6623b902e 100755 --- a/gn/command/npm_util.py +++ b/gn/command/npm_util.py @@ -59,20 +59,14 @@ def run(args, dir = None): if os.environ.get("KOALA_LOG_STDOUT"): subprocess.run(["npm"] + args, env=os.environ, text=True, check=True, stderr=subprocess.STDOUT) return - try: - ret = subprocess.run(["npm"] + args, capture_output=True, env=os.environ, text=True, check=True) - with open(koala_log, "a+") as f: - f.write("\n") - f.write(f"npm args: {args}; project: {project_path}:\n" + ret.stdout) - f.close() - except subprocess.CalledProcessError as e: - with open(koala_log, "a+") as f: - f.write("\n") - f.write("Error: " + e.stderr + "\n") - f.close() - print(f"Error: npm failure logged to {koala_log}") - print(open(koala_log, "r").read()) - raise + + result = subprocess.run(["npm"] + args, capture_output=True, env=os.environ, text=True) + with open(koala_log, "a+") as f: + f.write(f"npm args: {args}; project: {project_path}:\n" + result.stdout) + if result.returncode != 0: + f.write(f"npm args: {args}; project: {project_path}:\n" + result.stderr) + print(open(koala_log, "r").read()) + f.close() def install(dir = None): run(["install", "--registry", NPM_REPO, "--verbose"], dir or project_path) -- Gitee From 3d94671d83b9ede62d51e9a9a8b2ad0a3df8f99d Mon Sep 17 00:00:00 2001 From: Anton Tarasov Date: Fri, 8 Aug 2025 13:32:04 +0300 Subject: [PATCH 2/2] fix ex Signed-off-by: Anton Tarasov --- gn/command/npm_util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gn/command/npm_util.py b/gn/command/npm_util.py index e6623b902e..e32b92f359 100755 --- a/gn/command/npm_util.py +++ b/gn/command/npm_util.py @@ -66,6 +66,7 @@ def run(args, dir = None): if result.returncode != 0: f.write(f"npm args: {args}; project: {project_path}:\n" + result.stderr) print(open(koala_log, "r").read()) + raise Exception("npm failed") f.close() def install(dir = None): -- Gitee