Skip to content

Commit

Permalink
Require Node.js 12 and move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 28, 2021
1 parent 1f620db commit 7b785e3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 19 deletions.
3 changes: 0 additions & 3 deletions .github/funding.yml

This file was deleted.

5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Expand Up @@ -10,13 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 14
- 12
- 10
- 8
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
6 changes: 2 additions & 4 deletions index.d.ts
Expand Up @@ -3,7 +3,7 @@ Regular expression for matching [semver](https://github.com/npm/node-semver) ver
@example
```
import semverRegex = require('semver-regex');
import semverRegex from 'semver-regex';
semverRegex().test('v1.0.0');
//=> true
Expand All @@ -18,6 +18,4 @@ semverRegex().exec('unicorn 1.0.0 rainbow')[0];
//=> ['1.0.0', '2.1.3']
```
*/
declare function semverRegex(): RegExp;

export = semverRegex;
export default function semverRegex(): RegExp;
5 changes: 3 additions & 2 deletions index.js
@@ -1,2 +1,3 @@
'use strict';
module.exports = () => /(?<=^v?|\sv?)(?:(?:0|[1-9]\d*)\.){2}(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi;
export default function semverRegex() {
return /(?<=^v?|\sv?)(?:(?:0|[1-9]\d*)\.){2}(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi;
}
2 changes: 1 addition & 1 deletion index.test-d.ts
@@ -1,4 +1,4 @@
import {expectType} from 'tsd';
import semverRegex = require('.');
import semverRegex from './index.js';

expectType<RegExp>(semverRegex());
10 changes: 6 additions & 4 deletions package.json
Expand Up @@ -10,8 +10,10 @@
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -31,8 +33,8 @@
"semantic"
],
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.39.1"
}
}
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -11,7 +11,7 @@ $ npm install semver-regex
## Usage

```js
const semverRegex = require('semver-regex');
import semverRegex from 'semver-regex';

semverRegex().test('v1.0.0');
//=> true
Expand Down
2 changes: 1 addition & 1 deletion test.js
@@ -1,5 +1,5 @@
import test from 'ava';
import semverRegex from '.';
import semverRegex from './index.js';

const fixtures = [
'0.0.0',
Expand Down

0 comments on commit 7b785e3

Please sign in to comment.