Skip to content

Commit

Permalink
fix: runtime versions with a range
Browse files Browse the repository at this point in the history
  • Loading branch information
rigor789 committed Sep 10, 2021
1 parent 58a0e60 commit e0bbf1b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/services/project-data-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { IDictionary, IFileSystem, IProjectDir } from "../common/declarations";
import * as _ from "lodash";
import { IInjector } from "../common/definitions/yok";
import { injector } from "../common/yok";
import * as semver from "semver";

interface IProjectFileData {
projectData: any;
Expand Down Expand Up @@ -615,9 +616,12 @@ export class ProjectDataService implements IProjectDataService {
});

if (runtimePackage) {
// in case we are using a local tgz for the runtime
//
if (runtimePackage.version.includes("tgz")) {
const isRange =
semver.coerce(runtimePackage.version).version !==
runtimePackage.version;

// in case we are using a local tgz for the runtime or a range like ~8.0.0, ^8.0.0 etc.
if (runtimePackage.version.includes("tgz") || isRange) {
try {
const runtimePackageJsonPath = require.resolve(
`${runtimePackage.name}/package.json`,
Expand All @@ -629,7 +633,15 @@ export class ProjectDataService implements IProjectDataService {
runtimePackageJsonPath
).version;
} catch (err) {
runtimePackage.version = null;
if (isRange) {
runtimePackage.version = semver.coerce(
runtimePackage.version
).version;

(runtimePackage as any)._coerced = true;
} else {
runtimePackage.version = null;
}
}
}

Expand Down

0 comments on commit e0bbf1b

Please sign in to comment.