fix(pip): reset regex before each search

This commit is contained in:
Rhys Arkins 2018-06-05 10:18:13 +02:00
parent 05260a5b16
commit 775b2979eb
4 changed files with 9 additions and 1 deletions

View file

@ -18,6 +18,7 @@ function extractDependencies(content) {
const deps = content
.split('\n')
.map((line, lineNumber) => {
regex.lastIndex = 0;
const matches = regex.exec(line);
return (
matches && {

View file

@ -1,5 +1,6 @@
--index-url http://example.com/private-pypi/
# simple comment
some-package==0.3.1
some-other-package==1.0.0
not_semver==1.9

View file

@ -8,5 +8,11 @@ Array [
"lineNumber": 2,
"versionScheme": "pep440",
},
Object {
"currentValue": "1.0.0",
"depName": "some-other-package",
"lineNumber": 3,
"versionScheme": "pep440",
},
]
`;

View file

@ -20,7 +20,7 @@ describe('lib/manager/pip_requirements/extract', () => {
it('extracts dependencies', () => {
const res = extractDependencies(requirements, config).deps;
expect(res).toMatchSnapshot();
expect(res).toHaveLength(1);
expect(res).toHaveLength(2);
});
});
});