FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix `language: node` for hooks with build scripts and npm 11.x by asottile · Pull Request #3743 · pre-commit/pre-commit · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion pre_commit/languages/node.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,8 @@ def install_environment(
cmd_output_b(*cmd)

with in_env(prefix, version):
install = ('npm', 'install', '--allow-git=root', '-g', *pkgs)
install = (
'npm', 'install', '--allow-git=root', '--install-links', '-g',
*pkgs,
)
lang_base.setup_cmd(prefix, install)
15 changes: 15 additions & 0 deletions tests/languages/node_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ def test_node_hook_versions(tmp_path, version):
assert ret == (0, b'Hello World\n')


def test_npm_install_succeeds_with_build(tmp_path):
_make_hello_world(tmp_path)

with open(tmp_path.joinpath('package.json')) as f:
contents = json.load(f)
contents['scripts'] = {'build': 'echo hello hello'}
with open(tmp_path.joinpath('package.json'), 'w') as f:
json.dump(contents, f)
_make_repo(tmp_path)

# node version chosen to be npm 11.19.0 with this particular bug
ret = run_language(tmp_path, node, 'node-hello', version='26.7.0')
assert ret == (0, b'Hello World\n')


def test_node_additional_deps(tmp_path):
_make_local_repo(str(tmp_path))
ret, out = run_language(tmp_path, node, 'npm ls -g', deps=('lodash',))
Expand Down
Loading

Back | FazBrowse Home | New Git URL