Skip to content

Commit 98dfa4b

Browse files
authored
Fix install-unstable-test-master for packages (#612)
1 parent bc3a165 commit 98dfa4b

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

lib/Install.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,28 +169,41 @@ function getDirectTestDependencies(
169169

170170
const PKG = 'elm-explorations/test';
171171
const VERSION = '1.2.2';
172+
const VERSION_RANGE = '1.2.2 <= v < 2.0.0';
173+
174+
function getExpectedVersion(
175+
project /*: typeof Project.Project */
176+
) /*: string */ {
177+
switch (project.elmJson.type) {
178+
case 'application':
179+
return VERSION;
180+
case 'package':
181+
return VERSION_RANGE;
182+
}
183+
}
172184

173185
async function installUnstableTestMaster(
174186
project /*: typeof Project.Project */
175187
) /*: Promise<void> */ {
176188
const directTestDependencies = getDirectTestDependencies(project);
177189
const actualVersion = directTestDependencies[PKG];
178-
if (actualVersion !== VERSION) {
190+
const expectedVersion = getExpectedVersion(project);
191+
if (actualVersion.replace(/\s/g, '') !== expectedVersion.replace(/\s/g, '')) {
179192
throw new Error(
180193
`
181194
Could not find ${JSON.stringify(PKG)}: ${JSON.stringify(
182-
VERSION
195+
expectedVersion
183196
)} in your elm.json file here:
184197
185198
${ElmJson.getPath(project.rootDir)}
186199
187200
This command only works if you have ${PKG} as a (direct) test-dependency,
188-
and only if you use version ${VERSION}.
201+
and only if you use ${JSON.stringify(expectedVersion)}.
189202
190203
${
191204
actualVersion === undefined
192205
? 'I could not find it at all.'
193-
: `You seem to be using version ${actualVersion}.`
206+
: `You seem to be using ${JSON.stringify(actualVersion)}.`
194207
}
195208
`.trim()
196209
);

0 commit comments

Comments
 (0)