From 8c382c0941c0078e6650f2dfe165ce6c89c44f9e Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 10 Aug 2023 08:43:20 -0700 Subject: [PATCH 1/3] micro adjustments --- CHANGELOG.md | 3 ++- src/esmockErr.js | 2 +- src/esmockIsLoader.js | 3 +-- src/esmockModule.js | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82fb563f..2365fbdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # changelog - * tbd + * 2.3.7 _Aug.11.2023_ * [normalize package.json url](https://github.com/iambumblehead/esmock/pull/225) and [reduce loc for loader verification](https://github.com/iambumblehead/esmock/pull/226) + * [small adjustments](https://github.com/iambumblehead/esmock/pull/227) reducing lines of code * 2.3.6 _Aug.07.2023_ * [resolve global mocking issues](https://github.com/iambumblehead/esmock/pull/224) when using mixed esm cjs import trees * 2.3.4 _Jul.30.2023_ diff --git a/src/esmockErr.js b/src/esmockErr.js index a43a590c..7ba66ac2 100644 --- a/src/esmockErr.js +++ b/src/esmockErr.js @@ -9,7 +9,7 @@ const errMissingLoader = () => + 'start the process using --loader=esmock.') const errModuleIdNoDefs = (moduleId, parent) => - new Error(`no mocks provided for module: "${moduleId}" (used by ${parent}`) + new Error(`no mocks provided for module: "${moduleId}" (used by ${parent})`) export default { errModuleIdNotFound, diff --git a/src/esmockIsLoader.js b/src/esmockIsLoader.js index 3aa07def..c4175b03 100644 --- a/src/esmockIsLoader.js +++ b/src/esmockIsLoader.js @@ -1,4 +1,3 @@ import { loaderIsVerified } from './esmockLoader.js' -export default (c => async () => - (c = c || loaderIsVerified(import.meta.url)))() +export default (c => () => (c = c || loaderIsVerified(import.meta.url)))() diff --git a/src/esmockModule.js b/src/esmockModule.js index 53e87e9a..1e863c99 100644 --- a/src/esmockModule.js +++ b/src/esmockModule.js @@ -17,7 +17,8 @@ const isDefaultIn = o => isObj(o) && 'default' in o const isDirPathRe = /^\.?\.?([a-zA-Z]:)?(\/|\\)/ const isMetaResolve = typeof import.meta.resolve === 'function' const nextId = ((id = 0) => () => ++id)() -const asFileURL = p => p.startsWith('file://') ? p : url.pathToFileURL(p) +const fileurlre = /^file:\/\// +const asFileURL = p => fileurlre.test(p) ? p : url.pathToFileURL(p) const objProto = Object.getPrototypeOf({}) const isPlainObj = o => Object.getPrototypeOf(o) === objProto @@ -147,9 +148,8 @@ const esmockModule = async (moduleId, parent, defs, gdefs, opt) => { const gkeys = gdefs ? Object.keys(gdefs) : [] const dkeys = defs ? Object.keys(defs) : [] - if (opt.strict === 3 && !gkeys.length && !dkeys.length) { + if (opt.strict === 3 && !gkeys.length && !dkeys.length) throw esmockErr.errModuleIdNoDefs(moduleId, parent) - } const treeid = typeof opt.id === 'number' ? opt.id : nextId() const treeidspec = `${moduleFileURL}?key=${treeid}&strict=${opt.strict}?` + [ From 55c1567591edb3bb79ab1876b650978812a5124f Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 10 Aug 2023 08:49:43 -0700 Subject: [PATCH 2/3] remove superfluous workflow comments --- .github/workflows/coverage.yml | 3 --- .github/workflows/npm-publish.yml | 3 --- .github/workflows/test.yml | 3 --- 3 files changed, 9 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 88c28765..f4cf4a13 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,6 +1,3 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - name: coverage on: diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index d8fb5d80..2157b7f6 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,6 +1,3 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - name: npm package on: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41ee3d40..dcc8a502 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,3 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - name: tests on: From 17b53c2020d9314f4961e8376c05aef8b4525cd2 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 10 Aug 2023 09:03:04 -0700 Subject: [PATCH 3/3] update PR link at CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2365fbdc..8d51cfce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ * 2.3.7 _Aug.11.2023_ * [normalize package.json url](https://github.com/iambumblehead/esmock/pull/225) and [reduce loc for loader verification](https://github.com/iambumblehead/esmock/pull/226) - * [small adjustments](https://github.com/iambumblehead/esmock/pull/227) reducing lines of code + * [small adjustments](https://github.com/iambumblehead/esmock/pull/228) reducing lines of code * 2.3.6 _Aug.07.2023_ * [resolve global mocking issues](https://github.com/iambumblehead/esmock/pull/224) when using mixed esm cjs import trees * 2.3.4 _Jul.30.2023_