Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tty: make process.binding('tty_wrap') internal #22477

Merged
merged 1 commit into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
'http_parser',
'process_wrap',
'v8',
'tty_wrap',
'stream_wrap',
'signal_wrap',
'crypto',
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const { internalBinding } = require('internal/bootstrap/loaders');
const { Process } = internalBinding('process_wrap');
const { WriteWrap } = internalBinding('stream_wrap');
const { Pipe, constants: PipeConstants } = process.binding('pipe_wrap');
const { TTY } = process.binding('tty_wrap');
const { TCP } = internalBinding('tcp_wrap');
const { TTY } = internalBinding('tty_wrap');
const { UDP } = process.binding('udp_wrap');
const SocketList = require('internal/socket_list');
const { owner_symbol } = require('internal/async_hooks').symbols;
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/dgram.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
const { codes } = require('internal/errors');
const { internalBinding } = require('internal/bootstrap/loaders');
const { UDP } = process.binding('udp_wrap');
const { isInt32 } = require('internal/validators');
const TTYWrap = process.binding('tty_wrap');
const { internalBinding } = require('internal/bootstrap/loaders');
const TTYWrap = internalBinding('tty_wrap');
const { UV_EINVAL } = internalBinding('uv');
const { ERR_INVALID_ARG_TYPE, ERR_SOCKET_BAD_TYPE } = codes;
const kStateSymbol = Symbol('state symbol');
Expand Down
6 changes: 4 additions & 2 deletions lib/internal/process/stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function getMainThreadStdio() {

function getStdin() {
if (stdin) return stdin;
const tty_wrap = process.binding('tty_wrap');
const { internalBinding } = require('internal/bootstrap/loaders');
const tty_wrap = internalBinding('tty_wrap');
const fd = 0;

switch (tty_wrap.guessHandleType(fd)) {
Expand Down Expand Up @@ -163,7 +164,8 @@ function setupProcessStdio({ getStdout, getStdin, getStderr }) {

function createWritableStdioStream(fd) {
var stream;
const tty_wrap = process.binding('tty_wrap');
const { internalBinding } = require('internal/bootstrap/loaders');
const tty_wrap = internalBinding('tty_wrap');

// Note stream._type is used for test-module-load-list.js

Expand Down
2 changes: 1 addition & 1 deletion lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const {
} = internalBinding('uv');

const { Buffer } = require('buffer');
const TTYWrap = process.binding('tty_wrap');
const TTYWrap = internalBinding('tty_wrap');
const { ShutdownWrap } = internalBinding('stream_wrap');
const {
TCP,
Expand Down
3 changes: 2 additions & 1 deletion lib/tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

const { inherits, _extend } = require('util');
const net = require('net');
const { TTY, isTTY } = process.binding('tty_wrap');
const { internalBinding } = require('internal/bootstrap/loaders');
const { TTY, isTTY } = internalBinding('tty_wrap');
const errors = require('internal/errors');
const {
ERR_INVALID_FD,
Expand Down
2 changes: 1 addition & 1 deletion src/tty_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ TTYWrap::TTYWrap(Environment* env,

} // namespace node

NODE_BUILTIN_MODULE_CONTEXT_AWARE(tty_wrap, node::TTYWrap::Initialize)
NODE_MODULE_CONTEXT_AWARE_INTERNAL(tty_wrap, node::TTYWrap::Initialize)
4 changes: 3 additions & 1 deletion test/parallel/test-accessor-properties.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-internals
'use strict';

require('../common');
Expand All @@ -9,7 +10,8 @@ const assert = require('assert');

// Objects that call StreamBase::AddMethods, when setting up
// their prototype
const TTY = process.binding('tty_wrap').TTY;
const { internalBinding } = require('internal/test/binding');
const TTY = internalBinding('tty_wrap').TTY;
const UDP = process.binding('udp_wrap').UDP;

{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-internals
'use strict';

require('../common');
Expand All @@ -9,7 +10,8 @@ require('../common');
const assert = require('assert');

// Or anything that calls StreamBase::AddMethods when setting up its prototype
const TTY = process.binding('tty_wrap').TTY;
const { internalBinding } = require('internal/test/binding');
const TTY = internalBinding('tty_wrap').TTY;

{
assert.strictEqual(TTY.prototype.propertyIsEnumerable('bytesRead'), false);
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-tty-backwards-api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Flags: --expose-internals
'use strict';
const common = require('../common');

const noop = () => {};
const TTY = process.binding('tty_wrap').TTY = function() {};
const { internalBinding } = require('internal/test/binding');
const TTY = internalBinding('tty_wrap').TTY = function() {};

TTY.prototype = {
setBlocking: noop,
Expand Down
4 changes: 3 additions & 1 deletion test/pseudo-tty/ref_keeps_node_running.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Flags: --expose-internals --no-warnings
'use strict';

require('../common');

const { TTY, isTTY } = process.binding('tty_wrap');
const { internalBinding } = require('internal/test/binding');
const { TTY, isTTY } = internalBinding('tty_wrap');
const strictEqual = require('assert').strictEqual;

strictEqual(isTTY(0), true, 'fd 0 is not a TTY');
Expand Down
2 changes: 1 addition & 1 deletion test/pseudo-tty/test-async-wrap-getasyncid-tty.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

const common = require('../common');
const assert = require('assert');
const tty_wrap = process.binding('tty_wrap');
const { internalBinding } = require('internal/test/binding');
const { TTYWRAP } = internalBinding('async_wrap').Providers;
const tty_wrap = internalBinding('tty_wrap');
const providers = { TTYWRAP };

// Make sure that the TTYWRAP Provider is tested.
Expand Down
4 changes: 3 additions & 1 deletion test/pseudo-tty/test-handle-wrap-isrefed-tty.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --expose-internals --no-warnings
'use strict';

// see also test/parallel/test-handle-wrap-isrefed.js
Expand All @@ -6,7 +7,8 @@ const common = require('../common');
const strictEqual = require('assert').strictEqual;
const ReadStream = require('tty').ReadStream;
const tty = new ReadStream(0);
const isTTY = process.binding('tty_wrap').isTTY;
const { internalBinding } = require('internal/test/binding');
const isTTY = internalBinding('tty_wrap').isTTY;
strictEqual(isTTY(0), true, 'tty_wrap: stdin is not a TTY');
strictEqual(Object.getPrototypeOf(tty._handle).hasOwnProperty('hasRef'),
true, 'tty_wrap: hasRef() missing');
Expand Down
4 changes: 3 additions & 1 deletion test/pseudo-tty/test-tty-window-size.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Flags: --expose-internals --no-warnings
'use strict';
const common = require('../common');
const assert = require('assert');
const { WriteStream } = require('tty');
const { TTY } = process.binding('tty_wrap');
const { internalBinding } = require('internal/test/binding');
const { TTY } = internalBinding('tty_wrap');
const getWindowSize = TTY.prototype.getWindowSize;

function monkeyPatchGetWindowSize(fn) {
Expand Down
2 changes: 1 addition & 1 deletion test/pseudo-tty/test-tty-wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('../common');

const { internalBinding } = require('internal/test/binding');
const { TTY } = process.binding('tty_wrap');
const { TTY } = internalBinding('tty_wrap');
const { WriteWrap } = internalBinding('stream_wrap');

const handle = new TTY(1);
Expand Down