import-in-the-middle 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js
CHANGED
|
@@ -51,7 +51,11 @@ function Hook(modules, options, hookFn) {
|
|
|
51
51
|
if (isBuiltin) {
|
|
52
52
|
name = name.replace(/^node:/, '')
|
|
53
53
|
} else {
|
|
54
|
-
|
|
54
|
+
if (name.startsWith('file://')) {
|
|
55
|
+
try {
|
|
56
|
+
name = fileURLToPath(name)
|
|
57
|
+
} catch (e) {}
|
|
58
|
+
}
|
|
55
59
|
const details = parse(name)
|
|
56
60
|
if (details) {
|
|
57
61
|
name = details.name
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "import-in-the-middle",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Intercept imports in Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "c8 --check-coverage --lines 90 imhotap --runner test/runtest --files test/{hook,low-level,other}/*",
|
|
8
|
+
"test-win": "c8 --check-coverage --lines 90 imhotap --runner test\\runtest.bat --files test/{hook,low-level,other}/*",
|
|
8
9
|
"test:ts": "c8 imhotap --runner test/runtest --files test/typescript/*.test.mts",
|
|
10
|
+
"test-win:ts": "c8 imhotap --runner test\\runtest.bat --files test/typescript/*.test.mts",
|
|
9
11
|
"coverage": "c8 --reporter html imhotap --runner test/runtest --files test/{hook,low-level,other}/* && echo '\nNow open coverage/index.html\n'"
|
|
10
12
|
},
|
|
11
13
|
"repository": {
|
|
@@ -7,7 +7,7 @@ import { strictEqual } from 'assert'
|
|
|
7
7
|
const c8Dir = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'node_modules', 'c8')
|
|
8
8
|
|
|
9
9
|
Hook(['c8'], { internals: true }, (exports, name, baseDir) => {
|
|
10
|
-
strictEqual(name, 'c8
|
|
10
|
+
strictEqual(name, path.join('c8','index.js'))
|
|
11
11
|
strictEqual(baseDir, c8Dir)
|
|
12
12
|
exports.Report = () => 42
|
|
13
13
|
})
|
package/test/runtest
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const { spawn } = require('child_process')
|
|
8
8
|
const path = require('path')
|
|
9
|
+
const url = require('url')
|
|
9
10
|
|
|
10
11
|
process.env.NODE_NO_WARNINGS = 1
|
|
11
12
|
|
|
@@ -20,7 +21,7 @@ if (!filename.includes('disabled')) {
|
|
|
20
21
|
? path.join(__dirname, 'typescript', 'iitm-ts-node-loader.mjs')
|
|
21
22
|
: path.join(__dirname, '..', 'hook.mjs')
|
|
22
23
|
|
|
23
|
-
args.unshift(`--experimental-loader=${loaderPath}`)
|
|
24
|
+
args.unshift(`--experimental-loader=${url.pathToFileURL(loaderPath)}`)
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
spawn('node', args, { stdio: 'inherit' }).on('close', code => {
|
package/test/runtest.bat
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
node test/runtest %*
|