| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
the other branch which tried to solve this is here and my recommendation: #3259 (comment) |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
pretty sure in json mode it does a better job of obscuring the nonsense |
Sorry, something went wrong.
19d0b42 should do this, right? |
Sorry, something went wrong.
|
@asottile any chance to get this merged any soon? |
Sorry, something went wrong.
| "devDependencies": { | ||
| "typescript": "^5.3.0" | ||
| } |
There was a problem hiding this comment.
this is going to make the test prohibitively slow -- can you make a faster example?
Sorry, something went wrong.
Sorry, something went wrong.
|
|
||
|
|
||
| def get_npm_version() -> tuple[int, ...]: | ||
| _, out, _ = cmd_output('npm', '--version') | ||
| version_match = re.match(r'^(\d+)\.(\d+)\.(\d+)', out) | ||
|
|
||
| if version_match is None: | ||
| return 0, 0, 0 | ||
| else: | ||
| return tuple(map(int, version_match.groups())) |
There was a problem hiding this comment.
new code should not end up in utils -- also this is only used in one place
Sorry, something went wrong.
| # https://docs.npmjs.com/cli/v11/using-npm/changelog#1100-pre0-2024-11-26 | ||
| if npm_version >= (11, 0, 0): | ||
| args.append('--ignore-scripts') |
There was a problem hiding this comment.
this seems unrelated to your patch / not necessary
Sorry, something went wrong.
| except json.JSONDecodeError as e: | ||
| raise ValueError('Failed to parse npm pack output as JSON.') from e |
There was a problem hiding this comment.
just let it raise no reason to catch and reraise
Sorry, something went wrong.
| if not pkg_json: | ||
| raise ValueError('JSON array from npm pack is empty.') | ||
|
|
||
| if not isinstance(pkg_json, list): | ||
| raise ValueError('Expected npm pack output to be a JSON array.') | ||
|
|
||
| filename = pkg_json[0].get('filename') | ||
| if filename is None: | ||
| raise KeyError( | ||
| "Key 'filename' not found in the first element " | ||
| 'of the JSON array.', | ||
| ) |
There was a problem hiding this comment.
I would just let these raise
Sorry, something went wrong.
| def _make_hello_world(tmp_path, package_json=None): | ||
| package_json = package_json or '''\ |
There was a problem hiding this comment.
rather than changing this function -- call it and then write a package.json in the specific test below
Sorry, something went wrong.
| assert ret == (0, b'Hello World\n') | ||
|
|
||
|
|
||
| def test_node_with_prepare_script(tmp_path): |
There was a problem hiding this comment.
can you show the output of this failing before your patch?
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
That will fix pollution of installation path with TypeScript output: