Skip to content

Commit

Permalink
test(load-release-rules): limited loading to cjs files
Browse files Browse the repository at this point in the history
since we dont yet have a solution for loading from esm and are already limited to cjs in other areas

for #296
  • Loading branch information
travi committed May 26, 2023
1 parent e5f4580 commit ee05151
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'},
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/release-rules-invalid.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 42;
1 change: 0 additions & 1 deletion test/fixtures/release-rules-invalid.js

This file was deleted.

6 changes: 6 additions & 0 deletions test/fixtures/release-rules.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = [
{breaking: true, release: 'major'},
{type: 'feat', release: 'minor'},
{type: 'fix', release: 'patch'},
{type: 'perf', release: 'patch'},
];
6 changes: 0 additions & 6 deletions test/fixtures/release-rules.js

This file was deleted.

4 changes: 2 additions & 2 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
);

Expand Down Expand Up @@ -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/,
});
});
Expand Down
6 changes: 3 additions & 3 deletions test/load-release-rules.test.js
Original file line number Diff line number Diff line change
@@ -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();

Expand All @@ -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);
});
Expand Down Expand Up @@ -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/,
});
});
Expand Down

0 comments on commit ee05151

Please sign in to comment.