From ee05151a52168d05d939bbb909974b0955593087 Mon Sep 17 00:00:00 2001 From: Matt Travi Date: Fri, 26 May 2023 17:02:13 -0500 Subject: [PATCH] test(load-release-rules): limited loading to cjs files since we dont yet have a solution for loading from esm and are already limited to cjs in other areas for #296 --- README.md | 4 ++-- test/fixtures/release-rules-invalid.cjs | 1 + test/fixtures/release-rules-invalid.js | 1 - test/fixtures/release-rules.cjs | 6 ++++++ test/fixtures/release-rules.js | 6 ------ test/integration.test.js | 4 ++-- test/load-release-rules.test.js | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 test/fixtures/release-rules-invalid.cjs delete mode 100644 test/fixtures/release-rules-invalid.js create mode 100644 test/fixtures/release-rules.cjs delete mode 100644 test/fixtures/release-rules.js diff --git a/README.md b/README.md index 0b872811..fb75bc76 100644 --- a/README.md +++ b/README.md @@ -168,14 +168,14 @@ With this configuration: "plugins": [ ["@semantic-release/commit-analyzer", { "preset": "angular", - "releaseRules": "./config/release-rules.js" + "releaseRules": "./config/release-rules.cjs" }], "@semantic-release/release-notes-generator" ] } ``` ```js -// File: config/release-rules.js +// File: config/release-rules.cjs module.exports = [ {type: 'docs', scope: 'README', release: 'patch'}, {type: 'refactor', scope: 'core-*', release: 'minor'}, diff --git a/test/fixtures/release-rules-invalid.cjs b/test/fixtures/release-rules-invalid.cjs new file mode 100644 index 00000000..888cae37 --- /dev/null +++ b/test/fixtures/release-rules-invalid.cjs @@ -0,0 +1 @@ +module.exports = 42; diff --git a/test/fixtures/release-rules-invalid.js b/test/fixtures/release-rules-invalid.js deleted file mode 100644 index 7a4e8a72..00000000 --- a/test/fixtures/release-rules-invalid.js +++ /dev/null @@ -1 +0,0 @@ -export default 42; diff --git a/test/fixtures/release-rules.cjs b/test/fixtures/release-rules.cjs new file mode 100644 index 00000000..87297d18 --- /dev/null +++ b/test/fixtures/release-rules.cjs @@ -0,0 +1,6 @@ +module.exports = [ + {breaking: true, release: 'major'}, + {type: 'feat', release: 'minor'}, + {type: 'fix', release: 'patch'}, + {type: 'perf', release: 'patch'}, +]; diff --git a/test/fixtures/release-rules.js b/test/fixtures/release-rules.js deleted file mode 100644 index 6a399797..00000000 --- a/test/fixtures/release-rules.js +++ /dev/null @@ -1,6 +0,0 @@ -export default [ - { breaking: true, release: 'major' }, - { type: 'feat', release: 'minor' }, - { type: 'fix', release: 'patch' }, - { type: 'perf', release: 'patch' }, -]; diff --git a/test/integration.test.js b/test/integration.test.js index 9ac427ec..2c254603 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -117,7 +117,7 @@ test('Accept a "releaseRules" option that reference a requirable module', async {hash: '456', message: 'feat(scope2): Second feature'}, ]; const releaseType = await analyzeCommits( - {releaseRules: './test/fixtures/release-rules'}, + {releaseRules: './test/fixtures/release-rules.cjs'}, {cwd, commits, logger: t.context.logger} ); @@ -357,7 +357,7 @@ test('Throw error if "releaseRules" is not an Array or a String', async (t) => { }); test('Throw error if "releaseRules" option reference a requirable module that is not an Array or a String', async (t) => { - await t.throwsAsync(analyzeCommits({releaseRules: './test/fixtures/release-rules-invalid'}, {cwd}), { + await t.throwsAsync(analyzeCommits({releaseRules: './test/fixtures/release-rules-invalid.cjs'}, {cwd}), { message: /Error in commit-analyzer configuration: "releaseRules" must be an array of rules/, }); }); diff --git a/test/load-release-rules.test.js b/test/load-release-rules.test.js index 2d909672..53042568 100644 --- a/test/load-release-rules.test.js +++ b/test/load-release-rules.test.js @@ -1,6 +1,6 @@ import test from 'ava'; import loadReleaseRules from '../lib/load-release-rules.js'; -import testReleaseRules from './fixtures/release-rules.js'; +import testReleaseRules from './fixtures/release-rules.cjs'; const cwd = process.cwd(); @@ -11,7 +11,7 @@ test('Accept a "releaseRules" option', (t) => { }); test('Accept a "releaseRules" option that reference a requireable module', t => { - const releaseRules = loadReleaseRules({releaseRules: './test/fixtures/release-rules'}, {cwd}); + const releaseRules = loadReleaseRules({releaseRules: './test/fixtures/release-rules.cjs'}, {cwd}); t.deepEqual(releaseRules, testReleaseRules); }); @@ -58,7 +58,7 @@ test('Throw error if "releaseRules" is not an Array or a String', (t) => { }); test('Throw error if "releaseRules" option reference a requirable module that is not an Array or a String', (t) => { - t.throws(() => loadReleaseRules({releaseRules: './test/fixtures/release-rules-invalid'}, {cwd}), { + t.throws(() => loadReleaseRules({releaseRules: './test/fixtures/release-rules-invalid.cjs'}, {cwd}), { message: /Error in commit-analyzer configuration: "releaseRules" must be an array of rules/, }); });