diff options
-rw-r--r-- | ext/node/polyfills/process.ts | 12 | ||||
-rw-r--r-- | test_napi/common.js | 9 |
2 files changed, 16 insertions, 5 deletions
diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index 5c4720a8f..b0a4d04c8 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -8,6 +8,7 @@ const internals = globalThis.__bootstrap.internals; const { core } = globalThis.__bootstrap; import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts"; import { EventEmitter } from "node:events"; +import Module from "node:module"; import { validateString } from "ext:deno_node/internal/validators.mjs"; import { ERR_INVALID_ARG_TYPE, @@ -291,6 +292,15 @@ function _kill(pid: number, sig: number): number { } } +// TODO(bartlomieju): flags is currently not supported. +export function dlopen(module, filename, flags) { + if (typeof flags !== "undefined") { + warnNotImplemented("process.dlopen doesn't support 'flags' argument"); + } + Module._extensions[".node"](module, filename); + return module; +} + export function kill(pid: number, sig: string | number = "SIGTERM") { if (pid != (pid | 0)) { throw new ERR_INVALID_ARG_TYPE("pid", "number", pid); @@ -403,6 +413,8 @@ class Process extends EventEmitter { /** https://nodejs.org/api/process.html#process_process_nexttick_callback_args */ nextTick = _nextTick; + dlopen = dlopen; + /** https://nodejs.org/api/process.html#process_process_events */ override on(event: "exit", listener: (code: number) => void): this; override on( diff --git a/test_napi/common.js b/test_napi/common.js index ce9b2544b..5ad0e9cf3 100644 --- a/test_napi/common.js +++ b/test_napi/common.js @@ -7,6 +7,7 @@ export { assertThrows, } from "../test_util/std/testing/asserts.ts"; export { fromFileUrl } from "../test_util/std/path/mod.ts"; +import process from "node:process"; const targetDir = Deno.execPath().replace(/[^\/\\]+$/, ""); export const [libPrefix, libSuffix] = { @@ -15,13 +16,11 @@ export const [libPrefix, libSuffix] = { windows: ["", "dll"], }[Deno.build.os]; -const ops = Deno[Deno.internal].core.ops; - export function loadTestLibrary() { const specifier = `${targetDir}/${libPrefix}test_napi.${libSuffix}`; // Internal, used in ext/node - return ops.op_napi_open(specifier, { - Buffer: {}, - }); + const module = {}; + process.dlopen(module, specifier); + return module.exports; } |