mach: ohos: Print error message when hvigor fails (#34267)

`hvigorw --version` might fail if some required environment variables
are not set. In this case we should print the output of the command,
so that the user can report what caused `hvigorw --version` to fail.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2024-11-17 11:53:41 +01:00 committed by GitHub
parent dca33f681a
commit 0d2ce68d50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -224,6 +224,12 @@ class PackageCommands(CommandBase):
"path to hvigorw or set the HVIGOR_PATH environment variable to the npm"
"installation containing `node_modules` directory with hvigor modules.")
sys.exit(1)
except subprocess.CalledProcessError as e:
print(f"hvigor exited with the following error: {e}")
print(f"stdout: `{e.stdout}`")
print(f"stderr: `{e.stderr}`")
sys.exit(1)
else:
env["NODE_PATH"] = env["HVIGOR_PATH"] + "/node_modules"
hvigor_script = f"{env['HVIGOR_PATH']}/node_modules/@ohos/hvigor/bin/hvigor.js"