Skip to content

Commit

Permalink
Chore: Fix errors in release script
Browse files Browse the repository at this point in the history
Fix getting late output from exec calls (was being dropped).
Also fix handling null authors in release script.

- - - - - - - - - - - - - - - - - - - -

Close #5071
  • Loading branch information
antross committed Mar 3, 2022
1 parent 9a4d3b7 commit 81f5e3d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
16 changes: 10 additions & 6 deletions release/lib/git-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ const getResponseForCommitInfoRequest = async (commitSHA: string) => {

const commitInfo = result.data;

if (!commitInfo.author) {
debug(`No GitHub author found for commit ${commitSHA}`);

return null;
}

/*
* Get commit author related info.
*
Expand All @@ -89,21 +95,19 @@ const getResponseForCommitInfoRequest = async (commitSHA: string) => {
* which in most cases, is wrongly set.
*/

const cachedAuthor = commitInfo.author && authors.get(commitInfo.author.login);
const cachedAuthor = authors.get(commitInfo.author.login);

if (cachedAuthor) {
debug(`Reusing cached Author ${commitInfo.author?.login}`);
debug(`Reusing cached Author ${commitInfo.author.login}`);

return cachedAuthor;
}

debug(`Requesting info for login ${commitInfo.author?.login}`);
debug(`Requesting info for login ${commitInfo.author.login}`);

const responseForUserInfoRequestPromise = getResponseForUserInfoRequest(commitInfo);

if (commitInfo.author) {
authors.set(commitInfo.author.login, responseForUserInfoRequestPromise);
}
authors.set(commitInfo.author.login, responseForUserInfoRequestPromise);

return responseForUserInfoRequestPromise;
} catch (e) {
Expand Down
23 changes: 14 additions & 9 deletions scripts/utils/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,27 @@ const exec = (cmd, options = {}) => {
...options
});

command.stdout?.on('data', (data) => {
stdout += data;
});
if (command.stdout) {
command.stdout.on('data', (data) => {
stdout += data;
});

command.stdout.on('close', () => {
resolve({ stdout: stdout.trimEnd() });
});
}

command.on('error', (err) => {
return reject(err);
reject(err);
});

command.on('exit', (code) => {
if (code !== 0) {
return reject(new Error('NoExitCodeZero'));
if (code) {
reject(new Error(`Exit Code: ${code}\n${stdout}`));
} else if (!command.stdout) {
resolve({ stdout: '' });
}

return resolve({ stdout: stdout.trimEnd() });
});

});
};

Expand Down

0 comments on commit 81f5e3d

Please sign in to comment.