fix: Use JSON to parse npm pack output.

This commit is contained in:
Aleksey Ovcharenko 2025-09-26 17:52:09 +03:00
parent d2b61d0ef2
commit 24d595fc95
No known key found for this signature in database
GPG key ID: E8E4C43DA0B30C3B
3 changed files with 56 additions and 4 deletions

View file

@ -113,8 +113,8 @@ def test_installs_without_links_outside_env(tmpdir):
assert cmd_output('foo')[1] == 'success!\n'
def _make_hello_world(tmp_path):
package_json = '''\
def _make_hello_world(tmp_path, package_json=None):
package_json = package_json or '''\
{"name": "t", "version": "0.0.1", "bin": {"node-hello": "./bin/main.js"}}
'''
tmp_path.joinpath('package.json').write_text(package_json)
@ -132,6 +132,20 @@ def test_node_hook_system(tmp_path):
assert ret == (0, b'Hello World\n')
def test_node_with_prepare_script(tmp_path):
package_json = '''
{
"name": "t",
"version": "0.0.1",
"bin": {"node-hello": "./bin/main.js"},
"scripts": {"prepare": "echo prepare"}
}
'''
_make_hello_world(tmp_path, package_json)
ret = run_language(tmp_path, node, 'node-hello')
assert ret == (0, b'Hello World\n')
def test_node_with_user_config_set(tmp_path):
cfg = tmp_path.joinpath('cfg')
cfg.write_text('cache=/dne\n')