From fd51b2e506f3ea3cc49bfb2bcb19bc684f563f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 28 Nov 2022 21:59:36 +0100 Subject: fix(npm): allow to inspect npm modules with --inspect-brk (#16841) --- cli/node/mod.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cli/node') diff --git a/cli/node/mod.rs b/cli/node/mod.rs index fc4db33ee..fa6f0bdda 100644 --- a/cli/node/mod.rs +++ b/cli/node/mod.rs @@ -636,17 +636,22 @@ pub fn load_cjs_module_from_ext_node( js_runtime: &mut JsRuntime, module: &str, main: bool, + inspect_brk: bool, ) -> Result<(), AnyError> { fn escape_for_single_quote_string(text: &str) -> String { text.replace('\\', r"\\").replace('\'', r"\'") } let source_code = &format!( - r#"(function loadCjsModule(module) {{ + r#"(function loadCjsModule(module, inspectBrk) {{ + if (inspectBrk) {{ + Deno[Deno.internal].require.setInspectBrk(); + }} Deno[Deno.internal].require.Module._load(module, null, {main}); - }})('{module}');"#, + }})('{module}', {inspect_brk});"#, main = main, module = escape_for_single_quote_string(module), + inspect_brk = inspect_brk, ); js_runtime.execute_script(&located_script_name!(), source_code)?; -- cgit v1.2.3