Skip to content

Commit

Permalink
Merge pull request #228 from iambumblehead/fewer-loc-fileurl
Browse files Browse the repository at this point in the history
micro adjustments
  • Loading branch information
iambumblehead authored Aug 11, 2023
2 parents 1fdbf8c + 17b53c2 commit f824111
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 16 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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/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_
Expand Down
2 changes: 1 addition & 1 deletion src/esmockErr.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/esmockIsLoader.js
Original file line number Diff line number Diff line change
@@ -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)))()
6 changes: 3 additions & 3 deletions src/esmockModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}?` + [
Expand Down

0 comments on commit f824111

Please sign in to comment.