Node.js: renamed "require_shim" to "loader".
This commit is contained in:
@@ -39,7 +39,7 @@ multiple "targets" in Python applications.
|
||||
|
||||
<change type="feature">
|
||||
<para>
|
||||
a shim for automatic overriding "http" and "websocket" modules in Node.js.
|
||||
a loader for automatic overriding "http" and "websocket" modules in Node.js.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
if (module.parent && module.parent.id === "internal/preload") {
|
||||
const { Module } = require("module")
|
||||
|
||||
if (!Module.prototype.require.__unit_shim) {
|
||||
if (!Module.prototype.require.__unit_loader) {
|
||||
const http = require("./http")
|
||||
const websocket = require("./websocket")
|
||||
|
||||
@@ -22,6 +22,6 @@ if (module.parent && module.parent.id === "internal/preload") {
|
||||
return original.apply(this, arguments);
|
||||
}
|
||||
|
||||
Module.prototype.require.__unit_shim = true;
|
||||
Module.prototype.require.__unit_loader = true;
|
||||
}
|
||||
}
|
||||
@@ -19,13 +19,13 @@ class TestNodeApplication(TestApplicationNode):
|
||||
|
||||
self.assert_basic_application()
|
||||
|
||||
def test_node_application_require_shim_unit_http(self):
|
||||
self.load('require_shim/unit_http')
|
||||
def test_node_application_loader_unit_http(self):
|
||||
self.load('loader/unit_http')
|
||||
|
||||
self.assert_basic_application()
|
||||
|
||||
def test_node_application_require_shim_transitive_dependency(self):
|
||||
self.load('require_shim/transitive_dependency')
|
||||
def test_node_application_loader_transitive_dependency(self):
|
||||
self.load('loader/transitive_dependency')
|
||||
|
||||
self.assert_basic_application()
|
||||
|
||||
|
||||
@@ -20,18 +20,18 @@ class TestNodeESModules(TestApplicationNode):
|
||||
assert resp['headers']['Content-Type'] == 'text/plain', 'basic header'
|
||||
assert resp['body'] == 'Hello World\n', 'basic body'
|
||||
|
||||
def test_node_es_modules_require_shim_http(self):
|
||||
self.load('require_shim/es_modules_http', name="app.mjs")
|
||||
def test_node_es_modules_loader_http(self):
|
||||
self.load('loader/es_modules_http', name="app.mjs")
|
||||
|
||||
self.assert_basic_application()
|
||||
|
||||
def test_node_es_modules_require_shim_http_indirect(self):
|
||||
self.load('require_shim/es_modules_http_indirect', name="app.js")
|
||||
def test_node_es_modules_loader_http_indirect(self):
|
||||
self.load('loader/es_modules_http_indirect', name="app.js")
|
||||
|
||||
self.assert_basic_application()
|
||||
|
||||
def test_node_es_modules_require_shim_websockets(self):
|
||||
self.load('require_shim/es_modules_websocket', name="app.mjs")
|
||||
def test_node_es_modules_loader_websockets(self):
|
||||
self.load('loader/es_modules_websocket', name="app.mjs")
|
||||
|
||||
message = 'blah'
|
||||
|
||||
|
||||
@@ -31,14 +31,14 @@ class TestApplicationNode(TestApplicationProto):
|
||||
arguments = [
|
||||
"node",
|
||||
"--loader",
|
||||
"unit-http/require_shim.mjs",
|
||||
"unit-http/loader.mjs",
|
||||
"--require",
|
||||
"unit-http/require_shim",
|
||||
"unit-http/loader",
|
||||
name,
|
||||
]
|
||||
|
||||
else:
|
||||
arguments = ["node", "--require", "unit-http/require_shim", name]
|
||||
arguments = ["node", "--require", "unit-http/loader", name]
|
||||
|
||||
self._load_conf(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user