Skip to content

Commit 0a42541

Browse files
committed
fix(cli): allow * for version range
See #2028
1 parent ece2f7d commit 0a42541

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

packages/cli/lib/base-generator.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,12 @@ module.exports = class BaseGenerator extends Generator {
343343
const incompatibleDeps = {};
344344
for (const d in templateDeps) {
345345
const versionRange = projectDeps[d] || projectDevDeps[d];
346-
if (!versionRange || semver.intersects(versionRange, templateDeps[d]))
347-
continue;
346+
if (!versionRange) continue;
347+
// https://github.com/strongloop/loopback-next/issues/2028
348+
// https://github.com/npm/node-semver/pull/238
349+
// semver.intersects does not like `*`, `x`, or `X`
350+
if (versionRange.match(/^\*|x|X/)) continue;
351+
if (semver.intersects(versionRange, templateDeps[d])) continue;
348352
incompatibleDeps[d] = [versionRange, templateDeps[d]];
349353
}
350354

packages/cli/test/integration/lib/artifact-generator.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ module.exports = function(artiGenerator) {
9494
/Incompatible dependencies/,
9595
);
9696

97+
testCheckLoopBack(
98+
'allows */x/X for version range',
99+
{
100+
keywords: ['loopback'],
101+
devDependencies: {'@types/node': '*'},
102+
dependencies: {
103+
'@loopback/context': 'x.x',
104+
'@loopback/core': 'X.*',
105+
},
106+
},
107+
// No expected error here
108+
);
109+
97110
it('passes if "keywords" maps to "loopback"', async () => {
98111
gen.fs.readJSON.returns({keywords: ['test', 'loopback']});
99112
await gen.checkLoopBackProject();
@@ -110,6 +123,10 @@ module.exports = function(artiGenerator) {
110123
});
111124
gen.fs.readJSON.returns(obj);
112125
await gen.checkLoopBackProject();
126+
if (!expected) {
127+
assert(gen.exitGeneration == null);
128+
return;
129+
}
113130
assert(gen.exitGeneration instanceof Error);
114131
assert(gen.exitGeneration.message.match(expected));
115132
gen.end();

0 commit comments

Comments
 (0)