diff --git a/lib/updateDeps.js b/lib/updateDeps.js index 922fc54..b4d89b4 100644 --- a/lib/updateDeps.js +++ b/lib/updateDeps.js @@ -161,7 +161,7 @@ const resolveReleaseType = (pkg, bumpStrategy = "override", releaseStrategy = "p }; /** - * Get dependent release type by recursive scanning and updating its deps. + * Get dependent release type by recursive scanning and updating pkg deps. * * @param {Package} pkg The package with local deps to check. * @param {string} bumpStrategy Dependency resolution strategy: override, satisfy, inherit. @@ -173,6 +173,7 @@ const resolveReleaseType = (pkg, bumpStrategy = "override", releaseStrategy = "p const getDependentRelease = (pkg, bumpStrategy, releaseStrategy, ignore) => { const severityOrder = ["patch", "minor", "major"]; const { localDeps, manifest = {} } = pkg; + const lastVersion = pkg._lastRelease && pkg._lastRelease.version; const { dependencies = {}, devDependencies = {}, peerDependencies = {}, optionalDependencies = {} } = manifest; const scopes = [dependencies, devDependencies, peerDependencies, optionalDependencies]; const bumpDependency = (scope, name, nextVersion) => { @@ -194,23 +195,20 @@ const getDependentRelease = (pkg, bumpStrategy, releaseStrategy, ignore) => { return localDeps .filter((p) => !ignore.includes(p)) .reduce((releaseType, p) => { - const name = p.name; - // Has changed if... // 1. Any local dep package itself has changed // 2. Any local dep package has local deps that have changed. - const nextType = resolveReleaseType(p, bumpStrategy, releaseStrategy,[...ignore, ...localDeps]); - - // Set the nextVersion fallback to the last local dependency package last version - let nextVersion = p._lastRelease && p._lastRelease.version; - - // Update the nextVersion only if there is a next type to be bumped - if (nextType) nextVersion = p._preRelease ? getNextPreVersion(p) : getNextVersion(p); - const lastVersion = pkg._lastRelease && pkg._lastRelease.version; + const nextType = resolveReleaseType(p, bumpStrategy, releaseStrategy,[...ignore, p]); + const nextVersion = + nextType + // Update the nextVersion only if there is a next type to be bumped + ? p._preRelease ? getNextPreVersion(p) : getNextVersion(p) + // Set the nextVersion fallback to the last local dependency package last version + : p._lastRelease && p._lastRelease.version // 3. And this change should correspond to manifest updating rule. const requireRelease = scopes - .reduce((res, scope) => bumpDependency(scope, name, nextVersion) || res, !lastVersion) + .reduce((res, scope) => bumpDependency(scope, p.name, nextVersion) || res, !lastVersion) return requireRelease && (severityOrder.indexOf(nextType) > severityOrder.indexOf(releaseType)) ? nextType