Skip to content

Commit 3e8301d

Browse files
committed
fix: Converting packages to type: module to fix error with semantic-release/error package being esm only
1 parent 71f6bae commit 3e8301d

File tree

7 files changed

+17
-13
lines changed

7 files changed

+17
-13
lines changed

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const { createPublish } = require('./lib/publish');
2-
const { git } = require('./lib/git');
1+
import { createPublish } from './lib/publish';
2+
import { git } from './lib/git';
33

44
const publishTags = createPublish(git);
55
async function publish(pluginConfig, context) {
66
await publishTags(pluginConfig, context);
77
}
88

9-
module.exports = {
9+
export {
1010
publish
1111
};

lib/errors/GitError.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const SemanticReleaseError = require("@semantic-release/error");
1+
import SemanticReleaseError from "@semantic-release/error";
22

33
class GitError extends SemanticReleaseError {
44
constructor(originalError) {
@@ -9,6 +9,6 @@ class GitError extends SemanticReleaseError {
99
}
1010
}
1111

12-
module.exports = {
12+
export {
1313
GitError
1414
};

lib/git.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
const util = require('util');
2-
const exec = util.promisify(require('child_process').exec);
3-
const { GitError } = require('./errors/GitError');
1+
import { promisify } from 'util';
2+
import { exec as pureExec } from 'child_process';
3+
import { GitError } from './errors/GitError';
4+
5+
const exec = promisify(pureExec);
46

57
const git = {
68
forcePushTags: async ({sourceTag, targetTags, repositoryUrl}) => {
@@ -19,6 +21,6 @@ const git = {
1921
}
2022
}
2123

22-
module.exports = {
24+
export {
2325
git
2426
};

lib/publish.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { resolveTags } = require('./resolveTags');
1+
import { resolveTags } from './resolveTags';
22

33
function createPublish(git) {
44
return async (pluginConfig, context) => {
@@ -16,6 +16,6 @@ function createPublish(git) {
1616
}
1717
}
1818

19-
module.exports = {
19+
export {
2020
createPublish
2121
};

lib/resolveTags.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ function resolveTags(givenTag) {
44
return [major, `${major}.${minor}`];
55
}
66

7-
module.exports = {
7+
export {
88
resolveTags
99
};

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"version": "2.0.0",
44
"description": "Semantic Release Plugin to update all version Tags for a GitHub Action during a release",
55
"main": "index.js",
6+
"type": "module",
67
"contributors": [
78
"David Losert <[email protected]>"
89
],
910
"scripts": {
1011
"test": "vitest",
11-
"test:ci": "vitest"
12+
"test:ci": "vitest --coverage.enabled"
1213
},
1314
"repository": {
1415
"type": "git",

vitest.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default defineConfig({
44

55
test: {
66
coverage: {
7+
include: ['lib/**/*.js'],
78
// you can include other reporters, but 'json-summary' is required, json is recommended
89
reporter: ['text', 'json-summary', 'json'],
910
}

0 commit comments

Comments
 (0)