Skip to content

Commit

Permalink
test: formalize exposure of internal bindings
Browse files Browse the repository at this point in the history
moves exposed internalBindings to a single location with short
guidelines on how to expose them and a warning for users should they
come across it

PR-URL: #18698
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
devsnek committed Feb 10, 2018
1 parent 01d0491 commit 3e8af96
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
5 changes: 0 additions & 5 deletions lib/internal/loader/ModuleWrap.js

This file was deleted.

13 changes: 13 additions & 0 deletions lib/internal/test/binding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

process.emitWarning(
'These APIs are exposed only for testing and are not ' +
'tracked by any versioning system or deprecation process.',
'internal/test/binding');

// These exports should be scoped as specifically as possible
// to avoid exposing APIs because even with that warning and
// this file being internal people will still try to abuse it.
module.exports = {
ModuleWrap: internalBinding('module_wrap').ModuleWrap,
};
2 changes: 1 addition & 1 deletion node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
'lib/internal/loader/DefaultResolve.js',
'lib/internal/loader/ModuleJob.js',
'lib/internal/loader/ModuleMap.js',
'lib/internal/loader/ModuleWrap.js',
'lib/internal/loader/Translators.js',
'lib/internal/safe_globals.js',
'lib/internal/net.js',
Expand All @@ -125,6 +124,7 @@
'lib/internal/repl.js',
'lib/internal/repl/await.js',
'lib/internal/socket_list.js',
'lib/internal/test/binding.js',
'lib/internal/test/unicode.js',
'lib/internal/timers.js',
'lib/internal/tls.js',
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-internal-module-wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const common = require('../common');
common.crashOnUnhandledRejection();
const assert = require('assert');

const ModuleWrap = require('internal/loader/ModuleWrap');
const { ModuleWrap } = require('internal/test/binding');
const { getPromiseDetails, isPromise } = process.binding('util');
const setTimeoutAsync = require('util').promisify(setTimeout);

Expand Down

0 comments on commit 3e8af96

Please sign in to comment.