Support lifecycle scripts for node

The `npm pack` runs lifecycle scripts which can
spoil the standard output of the command and prevent
correct parsing of the created tarball.

For details see:

https://docs.npmjs.com/cli/v8/using-npm/scripts#life-cycle-scripts

Include a simple fix to parse out the tarball from the last line
and cover the fix with a simple test.

Signed-off-by: Miroslav Vadkerti <mvadkert@redhat.com>
This commit is contained in:
Miroslav Vadkerti 2024-07-17 21:28:47 +02:00
parent 0252908c27
commit 1cee8274a5
2 changed files with 17 additions and 3 deletions

View file

@ -99,7 +99,7 @@ def install_environment(
lang_base.setup_cmd(prefix, local_install_cmd)
_, pkg, _ = cmd_output('npm', 'pack', cwd=prefix.prefix_dir)
pkg = prefix.path(pkg.strip())
pkg = prefix.path(pkg.strip().split()[-1])
install = ('npm', 'install', '-g', pkg, *additional_dependencies)
lang_base.setup_cmd(prefix, install)