From e9286833bba539e4b10c6704e946b56b5deaa961 Mon Sep 17 00:00:00 2001 From: Vasil Rangelov Date: Fri, 26 Jul 2024 17:38:40 +0300 Subject: [PATCH] Use "node:" prefixed imports everywhere. Update minimum nodejs version to the ones where this feature was introduced, and update CI accordingly. Also bumped the mocha version to the latest one, as that one is still compatible with the now bumped nodejs version. --- .github/workflows/test.yml | 10 ++++++++-- index.js | 2 +- package.json | 4 ++-- test/errors.js | 2 +- test/invalid.js | 2 +- test/matching.js | 2 +- test/options.js | 2 +- test/padding.js | 2 +- test/support/exact.js | 4 ++-- test/verify-matches.js | 2 +- 10 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4569606..86f2d5e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,15 +15,21 @@ jobs: strategy: fail-fast: false matrix: - node: [8, 10, 12, 14, 16, 18, 20, 22] + node: [14.18.0, 14, 16.0.0, 16, 18, 20, 22] os: [ubuntu-latest, windows-latest, macOS-latest] + exclude: + # Node 14 is not available on macos anymore + - os: macos-latest + node-version: 14 + - os: macos-latest + node-version: 14.18.0 steps: - name: Clone repository uses: actions/checkout@v2 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} diff --git a/index.js b/index.js index ddb212e..cebc941 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ 'use strict'; -const util = require('util'); +const util = require('node:util'); const toRegexRange = require('to-regex-range'); const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val); diff --git a/package.json b/package.json index 582357f..b8331f3 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ ], "main": "index.js", "engines": { - "node": ">=8" + "node": ">=14.18.0 <15 || >=16" }, "scripts": { "lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives --ignore-path .gitignore .", @@ -35,7 +35,7 @@ }, "devDependencies": { "gulp-format-md": "^2.0.0", - "mocha": "^6.1.1", + "mocha": "^10.7.0", "nyc": "^15.1.0" }, "keywords": [ diff --git a/test/errors.js b/test/errors.js index 1a689b5..5bd1474 100644 --- a/test/errors.js +++ b/test/errors.js @@ -1,6 +1,6 @@ 'use strict'; -const assert = require('assert'); +const assert = require('node:assert'); const fill = require('..'); describe('error handling', () => { diff --git a/test/invalid.js b/test/invalid.js index bc2f3bc..f4ebe20 100644 --- a/test/invalid.js +++ b/test/invalid.js @@ -1,6 +1,6 @@ 'use strict'; -const assert = require('assert'); +const assert = require('node:assert'); const fill = require('..'); describe('invalid ranges', () => { diff --git a/test/matching.js b/test/matching.js index b8283bb..b8704f8 100644 --- a/test/matching.js +++ b/test/matching.js @@ -1,6 +1,6 @@ 'use strict'; -const assert = require('assert'); +const assert = require('node:assert'); const fill = require('..'); const toRegex = (...args) => new RegExp(`^(${fill(...args)})$`); diff --git a/test/options.js b/test/options.js index 2c7ea62..d7e773d 100644 --- a/test/options.js +++ b/test/options.js @@ -1,6 +1,6 @@ 'use strict'; -const assert = require('assert'); +const assert = require('node:assert'); const exact = require('./support/exact'); const fill = require('..'); diff --git a/test/padding.js b/test/padding.js index c763b49..de78302 100644 --- a/test/padding.js +++ b/test/padding.js @@ -1,6 +1,6 @@ 'use strict'; -const assert = require('assert').strict; +const assert = require('node:assert').strict; const fill = require('..'); describe('padding: numbers', () => { diff --git a/test/support/exact.js b/test/support/exact.js index 012add6..d5a7b39 100644 --- a/test/support/exact.js +++ b/test/support/exact.js @@ -1,7 +1,7 @@ 'use strict'; -const assert = require('assert'); -const util = require('util'); +const assert = require('node:assert'); +const util = require('node:util'); module.exports = (actual, expected) => { assert(Array.isArray(actual)); diff --git a/test/verify-matches.js b/test/verify-matches.js index f0fb671..a79fb30 100644 --- a/test/verify-matches.js +++ b/test/verify-matches.js @@ -7,7 +7,7 @@ 'use strict'; -const assert = require('assert'); +const assert = require('node:assert'); const expand = require('./support/expand'); const fill = require('..'); let count = 0;