Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Proper way of findingnpm packfilename output.#3460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ovcharenko wants to merge1 commit intopre-commit:main
base:main
Choose a base branch
Loading
fromovcharenko:main

Conversation

@ovcharenko
Copy link

That will fix pollution of installation path with TypeScript output:

E           pre_commit.util.CalledProcessError: command: ('/private/var/folders/sd/qk6llt717b99lp1wgtym5qwm0000gn/T/pytest-of-local.user/pytest-16/test_node_typescript_hook_syst0/node_env-system/bin/node','/opt/homebrew/bin/npm','install','-g','/private/var/folders/sd/qk6llt717b99lp1wgtym5qwm0000gn/T/pytest-of-local.user/pytest-16/test_node_typescript_hook_syst0/> t@0.0.1 prepare\n> tsc\n\nt-0.0.1.tgz')Ereturn code: 254E           stdout: (none)E           stderr:E               npm warn tarball tarball datafor file:/private/var/folders/sd/qk6llt717b99lp1wgtym5qwm0000gn/T/pytest-of-local.user/pytest-16/test_node_typescript_hook_syst0/> t@0.0.1 prepare> tsct-0.0.1.tgz (null) seems to be corrupted. Trying again.E               npm warn tarball tarball datafor file:/private/var/folders/sd/qk6llt717b99lp1wgtym5qwm0000gn/T/pytest-of-local.user/pytest-16/test_node_typescript_hook_syst0/> t@0.0.1 prepare> tsct-0.0.1.tgz (null) seems to be corrupted. Trying again.E               npm error code ENOENTE               npm error syscall openE               npm error path /private/var/folders/sd/qk6llt717b99lp1wgtym5qwm0000gn/T/pytest-of-local.user/pytest-16/test_node_typescript_hook_syst0/> t@0.0.1 prepare> tsct-0.0.1.tgzE               npm error errno -2E               npm error enoent ENOENT: no such file or directory, open'/private/var/folders/sd/qk6llt717b99lp1wgtym5qwm0000gn/T/pytest-of-local.user/pytest-16/test_node_typescript_hook_syst0/> t@0.0.1 prepare> tsct-0.0.1.tgz'E               npm error enoent This is related to npm not being able to find a file.E               npm error enoentE               npm error Acomplete log of this run can be found in: /Users/local.user/.npm/_logs/2025-05-09T10_21_58_861Z-debug-0.log

mm-chia reacted with rocket emoji
@asottile
Copy link
Member

the other branch which tried to solve this is here and my recommendation:#3259 (comment)

@ovcharenko
Copy link
Author

the other branch which tried to solve this is here and my recommendation:#3259 (comment)

That doesn't help much IMHO, because the JSON is part of other noisy output. So instead of one-line fix you will have to find JSON object and handle all error parsing.

@asottile
Copy link
Member

pretty sure in json mode it does a better job of obscuring the nonsense

@ovcharenko
Copy link
Author

pretty sure in json mode it does a better job of obscuring the nonsense

19d0b42 should do this, right?

@ovcharenkoovcharenko changed the titlefix: Process only the last line ofnpm pack output.fix: Proper way of findingnpm packfilename output.May 9, 2025
@ovcharenko
Copy link
Author

@asottile any chance to get this merged any soon?

Comment on lines 141 to 143
"devDependencies": {
"typescript": "^5.3.0"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this is going to make the test prohibitively slow -- can you make a faster example?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@asottile I took an example from#3259 instead. Will that work?

Comment on lines +241 to +250


defget_npm_version()->tuple[int, ...]:
_,out,_=cmd_output('npm','--version')
version_match=re.match(r'^(\d+)\.(\d+)\.(\d+)',out)

ifversion_matchisNone:
return0,0,0
else:
returntuple(map(int,version_match.groups()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

new code should not end up inutils -- also this is only used in one place

Comment on lines +106 to +108
# https://docs.npmjs.com/cli/v11/using-npm/changelog#1100-pre0-2024-11-26
ifnpm_version>= (11,0,0):
args.append('--ignore-scripts')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this seems unrelated to your patch / not necessary

Comment on lines +113 to +114
exceptjson.JSONDecodeErrorase:
raiseValueError('Failed to parse npm pack output as JSON.')frome
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

just let it raise no reason to catch and reraise

Comment on lines +116 to +127
ifnotpkg_json:
raiseValueError('JSON array from npm pack is empty.')

ifnotisinstance(pkg_json,list):
raiseValueError('Expected npm pack output to be a JSON array.')

filename=pkg_json[0].get('filename')
iffilenameisNone:
raiseKeyError(
"Key 'filename' not found in the first element "
'of the JSON array.',
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would just let these raise

Comment on lines +116 to +117
def_make_hello_world(tmp_path,package_json=None):
package_json=package_jsonor'''\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

rather than changing this function -- call it and then write a package.json in the specific test below

assertret== (0,b'Hello World\n')


deftest_node_with_prepare_script(tmp_path):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

can you show the output of this failing before your patch?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@asottileasottileasottile left review comments

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@ovcharenko@asottile

[8]ページ先頭

©2009-2025 Movatter.jp