diff --git a/README.md b/README.md index e098967..bae461a 100644 --- a/README.md +++ b/README.md @@ -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(); diff --git a/index.js b/index.js index 68800c2..4d24e8b 100644 --- a/index.js +++ b/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); @@ -7,4 +7,4 @@ module.exports = class SemanticReleaseError extends Error { this.details = details; this.semanticRelease = true; } -}; +} diff --git a/package.json b/package.json index 4c5b6f8..68fc1d5 100644 --- a/package.json +++ b/package.json @@ -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 (http://boennemann.me)", "ava": { "files": [ @@ -29,7 +30,7 @@ "semantic-release" ], "license": "MIT", - "main": "index.js", + "exports": "./index.js", "nyc": { "include": [ "index.js" diff --git a/test/helpers/inherited-error.js b/test/helpers/inherited-error.js index 79e90a8..870e40c 100644 --- a/test/helpers/inherited-error.js +++ b/test/helpers/inherited-error.js @@ -1,6 +1,6 @@ -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); @@ -8,4 +8,4 @@ module.exports = class InheritedError extends SemanticReleaseError { this.code = code; this.newProperty = 'newProperty'; } -}; +} diff --git a/test/helpers/throw-error.js b/test/helpers/throw-error.js index 070f802..229cb9d 100644 --- a/test/helpers/throw-error.js +++ b/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'); -}; +} diff --git a/test/index.test.js b/test/index.test.js index 5edf9df..289d060 100644 --- a/test/index.test.js +++ b/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);