Skip to content

Commit

Permalink
fix: Converting packages to type: module to fix error with semantic-r…
Browse files Browse the repository at this point in the history
…elease/error package being esm only
  • Loading branch information
davelosert committed Aug 23, 2024
1 parent 71f6bae commit 3e8301d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { createPublish } = require('./lib/publish');
const { git } = require('./lib/git');
import { createPublish } from './lib/publish';
import { git } from './lib/git';

const publishTags = createPublish(git);
async function publish(pluginConfig, context) {
await publishTags(pluginConfig, context);
}

module.exports = {
export {
publish
};
4 changes: 2 additions & 2 deletions lib/errors/GitError.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const SemanticReleaseError = require("@semantic-release/error");
import SemanticReleaseError from "@semantic-release/error";

class GitError extends SemanticReleaseError {
constructor(originalError) {
Expand All @@ -9,6 +9,6 @@ class GitError extends SemanticReleaseError {
}
}

module.exports = {
export {
GitError
};
10 changes: 6 additions & 4 deletions lib/git.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const util = require('util');
const exec = util.promisify(require('child_process').exec);
const { GitError } = require('./errors/GitError');
import { promisify } from 'util';
import { exec as pureExec } from 'child_process';
import { GitError } from './errors/GitError';

const exec = promisify(pureExec);

const git = {
forcePushTags: async ({sourceTag, targetTags, repositoryUrl}) => {
Expand All @@ -19,6 +21,6 @@ const git = {
}
}

module.exports = {
export {
git
};
4 changes: 2 additions & 2 deletions lib/publish.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolveTags } = require('./resolveTags');
import { resolveTags } from './resolveTags';

function createPublish(git) {
return async (pluginConfig, context) => {
Expand All @@ -16,6 +16,6 @@ function createPublish(git) {
}
}

module.exports = {
export {
createPublish
};
2 changes: 1 addition & 1 deletion lib/resolveTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ function resolveTags(givenTag) {
return [major, `${major}.${minor}`];
}

module.exports = {
export {
resolveTags
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
"version": "2.0.0",
"description": "Semantic Release Plugin to update all version Tags for a GitHub Action during a release",
"main": "index.js",
"type": "module",
"contributors": [
"David Losert <[email protected]>"
],
"scripts": {
"test": "vitest",
"test:ci": "vitest"
"test:ci": "vitest --coverage.enabled"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default defineConfig({

test: {
coverage: {
include: ['lib/**/*.js'],
// you can include other reporters, but 'json-summary' is required, json is recommended
reporter: ['text', 'json-summary', 'json'],
}
Expand Down

0 comments on commit 3e8301d

Please sign in to comment.