Skip to content

Commit

Permalink
feat: download the latest version instead of a pinned one
Browse files Browse the repository at this point in the history
Fixes: #93
  • Loading branch information
aduh95 committed Jun 26, 2022
1 parent 2470f58 commit 88f6807
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sources/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import defaultConfig from '../config.js

import * as corepackUtils from './corepackUtils';
import * as folderUtils from './folderUtils';
import {fetchAsJson} from './httpUtils';
import * as semverUtils from './semverUtils';
import {Config, Descriptor, Locator} from './types';
import {SupportedPackageManagers, SupportedPackageManagerSet} from './types';
Expand Down Expand Up @@ -69,17 +70,16 @@ export class Engine {
// Ignore errors; too bad
}

if (typeof lastKnownGood !== `object` || lastKnownGood === null)
return definition.default;

if (!Object.prototype.hasOwnProperty.call(lastKnownGood, packageManager))
return definition.default;

const override = (lastKnownGood as any)[packageManager];
if (typeof override !== `string`)
return definition.default;
if (typeof lastKnownGood === `object` && lastKnownGood !== null &&
Object.prototype.hasOwnProperty.call(lastKnownGood, packageManager)) {
const override = (lastKnownGood as any)[packageManager];
if (typeof override === `string`) {
return override;
}
}

return override;
const latest = await fetchAsJson(`https://registry.npmjs.org/${packageManager}`);
return latest[`dist-tags`].latest;
}

async activatePackageManager(locator: Locator) {
Expand Down

0 comments on commit 88f6807

Please sign in to comment.