Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

Commit 6b245c7

Browse files
authored
Merge pull request #76 from addaleax/no-process-binding
fix: Avoid using process.binding()
2 parents 1e1f99f + fbec9db commit 6b245c7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

lib/internal/inspect_repl.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,16 @@ function extractFunctionName(description) {
8585
return fnNameMatch ? `: ${fnNameMatch[1]}` : '';
8686
}
8787

88-
const NATIVES = process.binding('natives');
88+
const PUBLIC_BUILTINS = require('module').builtinModules;
89+
const NATIVES = PUBLIC_BUILTINS ? process.binding('natives') : {};
8990
function isNativeUrl(url) {
90-
return url.replace('.js', '') in NATIVES || url === 'bootstrap_node.js';
91+
url = url.replace(/\.js$/, '');
92+
if (PUBLIC_BUILTINS) {
93+
if (url.startsWith('internal/') || PUBLIC_BUILTINS.includes(url))
94+
return true;
95+
}
96+
97+
return url in NATIVES || url === 'bootstrap_node';
9198
}
9299

93100
function getRelativePath(filenameOrURL) {

0 commit comments

Comments
 (0)