Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing issues #47

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions utils.js
Expand Up @@ -260,8 +260,13 @@ const parseYarnLock = async function (yarnLockFile) {
return;
}
if (!l.startsWith(" ")) {
const tmpA = l.split("@");
if (tmpA.length == 2) {
// strip surrounding quotes, if any
const tmpA = l.replace(/["']/g, '').split("@");
// ignore possible leading empty strings
if (tmpA[0] === '') {
tmpA.shift();
}
if (tmpA.length >= 2) {
const fullName = tmpA[0];
if (fullName.indexOf("/") > -1) {
const parts = fullName.split("/");
Expand Down
12 changes: 6 additions & 6 deletions utils.test.js
Expand Up @@ -576,7 +576,7 @@ test("parsePnpmLock", async () => {

test("parseYarnLock", async () => {
let deps = await utils.parseYarnLock("./test/yarn.lock");
expect(deps.length).toEqual(51);
expect(deps.length).toEqual(56);
expect(deps[0]).toEqual({
group: '',
name: 'asap',
Expand All @@ -585,12 +585,12 @@ test("parseYarnLock", async () => {
});

deps = await utils.parseYarnLock("./test/data/yarn_locks/yarn.lock");
expect(deps.length).toEqual(1463);
expect(deps.length).toEqual(2029);
expect(deps[0]).toEqual({
group: '',
name: 'JSONStream',
version: '4.2.2',
_integrity: 'sha256-d291c6a4e97989b5c61d9acf396ae4fe133a718d'
group: 'babel',
name: 'cli',
version: '7.10.1',
_integrity: 'sha256-b6e5cd43a17b8f639442ab027976408ebe6d79a0'
});
deps.forEach(d => {
expect(d.name).toBeDefined();
Expand Down