Skip to content

Commit

Permalink
fix(recursive): sorting prerelease packages
Browse files Browse the repository at this point in the history
close #2279
  • Loading branch information
zkochan committed Mar 30, 2020
1 parent a00cd5f commit e2d345e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/pkgs-graph/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export default function<T> (pkgs: Array<Package & T>): {
const matchedPkg = pkgs.find(pkg => pkg.manifest.name === depName && pkg.manifest.version === rawSpec)
return matchedPkg!.dir
}
const matched = semver.maxSatisfying(versions, rawSpec)
const matched = rawSpec === '*'
? semver.maxSatisfying(versions, rawSpec, { includePrerelease: true })
: semver.maxSatisfying(versions, rawSpec)
if (!matched) {
unmatched.push({ pkgName: depName, range: rawSpec })
return ''
Expand Down
51 changes: 51 additions & 0 deletions packages/pkgs-graph/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,54 @@ test('create package graph ignoring the workspace protocol', t => {
})
t.end()
})

test('* matches prerelease versions', t => {
const result = createPkgGraph([
{
dir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',

dependencies: {
'foo': '*',
},
},
},
{
dir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0-0',
},
},
])
t.deepEqual(result.unmatched, [])
t.deepEqual(result.graph, {
[BAR1_PATH]: {
dependencies: [FOO1_PATH],
package: {
dir: BAR1_PATH,
manifest: {
name: 'bar',
version: '1.0.0',

dependencies: {
'foo': '*',
},
},
},
},
[FOO1_PATH]: {
dependencies: [],
package: {
dir: FOO1_PATH,
manifest: {
name: 'foo',
version: '1.0.0-0',
},
},
},
})
t.end()
})

0 comments on commit e2d345e

Please sign in to comment.