Skip to content

Commit

Permalink
refactor(esm): converted the package to esm-only
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `@semantic-release/error` is now an ES Module

fixes #247
  • Loading branch information
travi committed Jun 7, 2023
1 parent f0069bf commit 7df5e62
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -11,7 +11,7 @@ Any other type of error will be considered by [semantic-release](https://github.
## Usage

```js
const SemanticReleaseError = require("@semantic-release/error");
import SemanticReleaseError from "@semantic-release/error";

// Default
throw new SemanticReleaseError();
Expand Down
4 changes: 2 additions & 2 deletions index.js
@@ -1,4 +1,4 @@
module.exports = class SemanticReleaseError extends Error {
export default class SemanticReleaseError extends Error {
constructor(message, code, details) {
super(message);
Error.captureStackTrace(this, this.constructor);
Expand All @@ -7,4 +7,4 @@ module.exports = class SemanticReleaseError extends Error {
this.details = details;
this.semanticRelease = true;
}
};
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -2,6 +2,7 @@
"name": "@semantic-release/error",
"description": "errors with more than just a message",
"version": "0.0.0-development",
"type": "module",
"author": "Stephan Bönnemann <[email protected]> (http://boennemann.me)",
"ava": {
"files": [
Expand Down Expand Up @@ -29,7 +30,7 @@
"semantic-release"
],
"license": "MIT",
"main": "index.js",
"exports": "./index.js",
"nyc": {
"include": [
"index.js"
Expand Down
6 changes: 3 additions & 3 deletions test/helpers/inherited-error.js
@@ -1,11 +1,11 @@
const SemanticReleaseError = require('../../index.js');
import SemanticReleaseError from '../../index.js';

module.exports = class InheritedError extends SemanticReleaseError {
export default class InheritedError extends SemanticReleaseError {
constructor(message, code) {
super(message);
Error.captureStackTrace(this, this.constructor);
this.name = 'InheritedError';
this.code = code;
this.newProperty = 'newProperty';
}
};
}
6 changes: 3 additions & 3 deletions test/helpers/throw-error.js
@@ -1,5 +1,5 @@
const SemanticReleaseError = require('../../index.js');
import SemanticReleaseError from '../../index.js';

module.exports = () => {
export default () => {
throw new SemanticReleaseError('message', 'code');
};
}
12 changes: 6 additions & 6 deletions test/index.test.js
@@ -1,10 +1,10 @@
const test = require('ava');
const throwError = require('./helpers/throw-error.js');
const InheritedError = require('./helpers/inherited-error.js');
const throwInheritedError = require('./helpers/throw-inherited-error.js');
const SemanticReleaseError = require('..');
import test from 'ava';
import throwError from './helpers/throw-error.js';
import InheritedError from './helpers/inherited-error.js';
import throwInheritedError from './helpers/throw-inherited-error.js';
import SemanticReleaseError from '../index.js';

test('Instanciates error', (t) => {
test('Instantiates error', (t) => {
const error = new SemanticReleaseError();

t.true(error instanceof Error);
Expand Down

0 comments on commit 7df5e62

Please sign in to comment.