Skip to content

Commit 551a2ff

Browse files
authored
fix error while parsing locally linked dependencies (#56)
1 parent 49be33b commit 551a2ff

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ const constructBerryEntry = entryLines => {
9494
.replaceAll(':', '')
9595
.split(',');
9696

97-
const endFields = entryLines.splice(-4);
97+
const version = entryLines[1].split('version: ')[1];
98+
const isLocal = version.includes('use.local');
99+
100+
const endFields = entryLines.splice(isLocal ? -3 : -4);
98101
const peerBlockStart = entryLines.findIndex(entry => entry.includes('peerDependencies:'));
99102
const peerFields =
100103
peerBlockStart !== -1 ? entryLines.splice(-(entryLines.length - peerBlockStart)) : undefined;
@@ -113,15 +116,15 @@ const constructBerryEntry = entryLines => {
113116
)
114117
: undefined;
115118

116-
const integrity = endFields[0].split('checksum: ')[1];
119+
const integrity = !isLocal && endFields[0].split('checksum: ')[1];
117120
const resolution = entryLines[2].split('resolution: ')[1];
118121

119122
const entryObject = {
120-
version: entryLines[1].split('version: ')[1],
123+
version,
121124
resolved: resolution.includes('@workspace:') ? 'workspace' : resolution,
122125
integrity,
123-
language: endFields[1].split('languageName: ')[1],
124-
link: endFields[2].split('linkType: ')[1],
126+
language: endFields[isLocal ? 0 : 1].split('languageName: ')[1],
127+
link: endFields[isLocal ? 1 : 2].split('linkType: ')[1],
125128
dependencies,
126129
peerDependencies
127130
};
@@ -167,6 +170,7 @@ export const parseLock = content => {
167170
}, []);
168171

169172
const result = entryChunks
173+
.filter(entryLines => entryLines.length >= 4)
170174
.map(entryLines =>
171175
metadata.version === 1 ? constructClassicEntry(entryLines) : constructBerryEntry(entryLines)
172176
)

0 commit comments

Comments
 (0)