From d0edd29b861584808f6c0ba0edf7c391d3ddcb33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bonnet?= Date: Fri, 9 Jun 2023 11:23:42 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20E2E=20tests=20and=20semver?= =?UTF-8?q?=20validation=20error=20type=20(#250)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/gitmoji-changelog-cli/src/cli.e2e.js | 2 +- packages/gitmoji-changelog-cli/src/cli.js | 4 ++-- packages/gitmoji-changelog-core/src/index.js | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/gitmoji-changelog-cli/src/cli.e2e.js b/packages/gitmoji-changelog-cli/src/cli.e2e.js index e6b5e2d..9f86984 100644 --- a/packages/gitmoji-changelog-cli/src/cli.e2e.js +++ b/packages/gitmoji-changelog-cli/src/cli.e2e.js @@ -443,7 +443,7 @@ describe('generate changelog', () => { }) async function makeChanges(fileName) { - fs.writeFileSync(path.join(testDir, fileName)) + fs.writeFileSync(path.join(testDir, fileName), '') } async function makeCustomConfig(config) { diff --git a/packages/gitmoji-changelog-cli/src/cli.js b/packages/gitmoji-changelog-cli/src/cli.js index 24ef57f..03936bd 100644 --- a/packages/gitmoji-changelog-cli/src/cli.js +++ b/packages/gitmoji-changelog-cli/src/cli.js @@ -6,7 +6,7 @@ const semver = require('semver') const semverCompare = require('semver-compare') const rc = require('rc') -const { generateChangelog, logger } = require('@gitmoji-changelog/core') +const { generateChangelog, logger, FunctionalError } = require('@gitmoji-changelog/core') const { buildMarkdownFile, getLatestVersion } = require('@gitmoji-changelog/markdown') const issueReporter = require('issue-reporter') @@ -138,7 +138,7 @@ async function getChangelog(options, projectInfo) { const release = options.release === 'from-package' ? projectInfo.version : options.release if (!semver.valid(release)) { - throw new Error(`${release} is not a valid semver version.`) + throw new FunctionalError(`${release} is not a valid semver version.`) } const enhancedOptions = { diff --git a/packages/gitmoji-changelog-core/src/index.js b/packages/gitmoji-changelog-core/src/index.js index 0800797..8143a40 100644 --- a/packages/gitmoji-changelog-core/src/index.js +++ b/packages/gitmoji-changelog-core/src/index.js @@ -187,4 +187,5 @@ function getLastCommitDate(commits) { module.exports = { generateChangelog, logger, + FunctionalError, }