Skip to content

Commit

Permalink
fix: ignore pip install .whl file (#142)
Browse files Browse the repository at this point in the history
Continue of #140 
Close #119 

I added a change for ignore commands that end with `.whl`,
and I also added an example to real-examples.yaml

---------

Co-authored-by: Baruch Odem <baruch.odem@checkmarx.com>
Co-authored-by: Baruch Odem (Rothkoff) <baruchiro@gmail.com>
  • Loading branch information
3 people authored Jul 30, 2023
1 parent dcdf44f commit bda5fc7
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 17 deletions.
5 changes: 5 additions & 0 deletions src/content/registry/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ const handleArgument = (argument, restCommandWords) => {

const baseCommandMatch = (line) => line.match(/pip3? +install/);
const packageWordParse = (word) => {
if (word.endsWith('.whl')) {
console.debug('Ignoring package with ".whl":', word);
return null;
}

const match = word.match(packageArea);
if (!match) return null;

Expand Down
1 change: 1 addition & 0 deletions src/content/registry/python.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe(parseCommand.name, () => {
'install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl',
'install MySQL_python==', // Although this is a valid package name, it's not a valid command
'install -r requirements.txt',
'install scipy-0.16.1-cp27-none-win_amd64.whl',
];
const createCommand = (packageManager) => commands.map((command) => `${packageManager} ${command}`);

Expand Down
117 changes: 100 additions & 17 deletions tests/real-examples/real-examples-results.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/real-examples/real-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ links:
comment: pip3 install command
post: answer
registry: pypi
https://stackoverflow.com/a/33984261:
comment: should Ignore this .whl as a package
post: answer
registry: pypi

https://stackoverflow.com/a/27709931:
comment: go get standard library
Expand Down

0 comments on commit bda5fc7

Please sign in to comment.