Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #580 from zarathustra323/dep-tool-prerelease
Browse files Browse the repository at this point in the history
Allow `--latest` to also include prereleases if flagged
  • Loading branch information
zarathustra323 authored Feb 17, 2023
2 parents 72ec644 + ca97f22 commit 6c640c6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/dependency-tool/src/commands/upgrade/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const loadWorkspaceDirs = require('./load-workspace-dirs');

const { isArray } = Array;

const execute = async ({ dir, forceLatest }) => {
const execute = async ({ dir, forceLatest, prereleases }) => {
const pkg = loadPackage({ dir });
log(chalk`Loaded package {magenta ${pkg.name}}`);
const baseDepMap = exractDeps(pkg);
Expand All @@ -23,7 +23,9 @@ const execute = async ({ dir, forceLatest }) => {
const packageVersionMap = new Map();
await Promise.all([...names].map(async (name) => {
const { versions } = await loadVersionInfo(name);
const latest = versions.filter(v => !semver.prerelease(v)).pop();
const latest = prereleases
? [...versions].pop()
: versions.filter(v => !semver.prerelease(v)).pop();
packageVersionMap.set(name, { versions, latest });
}));

Expand Down Expand Up @@ -60,11 +62,11 @@ const execute = async ({ dir, forceLatest }) => {
}
};

module.exports = ({ path, latest: forceLatest = false }) => {
module.exports = ({ path, latest: forceLatest = false, prereleases = false }) => {
const dir = cwd(path);
logCmd('upgrade', dir);

execute({ dir, forceLatest }).then(() => {
execute({ dir, forceLatest, prereleases }).then(() => {
exit(chalk`{green Upgrade complete!}`, 0);
}).catch((e) => {
exit(e.message);
Expand Down

0 comments on commit 6c640c6

Please sign in to comment.