mirror of
https://github.com/cycjimmy/semantic-release-action.git
synced 2025-11-07 10:46:56 +00:00
fix: improves result handling in windUpJob.task.js
Promise was checked before resolving, so the first early return never happened (Promises are truthy) and the subsequent `if (lastRelease.version)` check produced an error in some cases(`lastRelease` undefined, "Error: TypeError: Cannot read properties of undefined (reading 'version')"). Observed for semantic-release-action 4.2.2 and 5.0.0 with semantic_version > 24.2.6 (not observed with 24.2.6). The PR prevents reading properties of "undefined".
This commit is contained in:
parent
8e71605483
commit
4267eee560
1 changed files with 12 additions and 6 deletions
|
|
@ -7,14 +7,20 @@ const outputs = require('./outputs.json');
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
module.exports = async (result) => {
|
module.exports = async (result) => {
|
||||||
if (!result) {
|
const resolved = await result;
|
||||||
|
if (!resolved) {
|
||||||
core.debug('No release published.');
|
core.debug('No release published.');
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {lastRelease, commits, nextRelease, releases} = await result;
|
const {
|
||||||
|
lastRelease = {},
|
||||||
|
commits = [],
|
||||||
|
nextRelease = {},
|
||||||
|
releases = [],
|
||||||
|
} = resolved;
|
||||||
|
|
||||||
if (lastRelease.version) {
|
if (lastRelease?.version) {
|
||||||
core.debug(`The last release was "${lastRelease.version}".`);
|
core.debug(`The last release was "${lastRelease.version}".`);
|
||||||
core.setOutput(outputs.last_release_version, lastRelease.version);
|
core.setOutput(outputs.last_release_version, lastRelease.version);
|
||||||
core.setOutput(outputs.last_release_git_head, lastRelease.gitHead);
|
core.setOutput(outputs.last_release_git_head, lastRelease.gitHead);
|
||||||
|
|
@ -23,7 +29,7 @@ module.exports = async (result) => {
|
||||||
|
|
||||||
if (!nextRelease) {
|
if (!nextRelease) {
|
||||||
core.debug('No release published.');
|
core.debug('No release published.');
|
||||||
return Promise.resolve();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
core.debug(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`);
|
core.debug(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue