Skip to content

Commit

Permalink
refactor: pass state using error object cause
Browse files Browse the repository at this point in the history
Fixes #1095
  • Loading branch information
juancarlosjr97 committed Apr 25, 2024
1 parent a381972 commit 131df45
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ const runTasks = async (opts, di) => {
const errorMessage = err.message || err;
const logger = log || console;

err.name === 'INFO' ? logger.info(errorMessage) : logger.error(errorMessage); // eslint-disable-line no-console
err.cause === 'INFO' ? logger.info(errorMessage) : logger.error(errorMessage);

throw err;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const parseVersion = raw => {
const e = (message, docs, fail = true) => {
const error = new Error(docs ? `${message}${EOL}Documentation: ${docs}${EOL}` : message);
error.code = fail ? 1 : 0;
error.name = fail ? error.name : 'INFO';
error.cause = fail ? 'ERROR' : 'INFO';
return error;
};

Expand Down
2 changes: 1 addition & 1 deletion test/git.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ test.serial('should not throw if there are commits', async t => {
const gitClient = factory(Git, { options });
sh.exec('git tag 1.0.0');
gitAdd('line', 'file', 'Add file');
await t.notThrowsAsync(gitClient.init());
await t.notThrowsAsync(gitClient.init(), 'There are no commits since the latest tag');
});

test.serial('should fail (exit code 1) if there are no commits', async t => {
Expand Down

0 comments on commit 131df45

Please sign in to comment.