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