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

[11.x] use NativeModuleLoader to compile all the bootstrappers #25446

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
617bfe4
lib: remove internalBinding('config').pendingDeprecation
joyeecheung Dec 11, 2018
c168672
inspector: move process.binding to internalBinding
BeniCheni Dec 10, 2018
dc4e5c5
util: inspect ArrayBuffers contents as well
BridgeAR Dec 13, 2018
0c67a51
lib: remove internal `util._extends()` usage
BridgeAR Dec 18, 2018
e97acf7
lib: expose all type checks from the internal types module
BridgeAR Dec 20, 2018
95fa3c7
buffer: inspect extra properties
BridgeAR Dec 20, 2018
7ff4402
lib: move lib/console.js to lib/internal/console/constructor.js
joyeecheung Nov 28, 2018
2f1f009
console: split console into global.js and constructor.js
joyeecheung Nov 28, 2018
6280cda
console: move the inspector console wrapping in a separate file
joyeecheung Nov 28, 2018
6bf7511
console: add `inspectOptions` option
BridgeAR Dec 12, 2018
049b24d
console: improve inspectOptions validation
cjihrig Dec 17, 2018
8d166c9
process: provide dummy stdio for non-console Windows apps
addaleax May 9, 2018
c219b8f
Revert "lib: expose all type checks from the internal types module"
joyeecheung Jan 11, 2019
f4dbe57
Revert "inspector: move process.binding to internalBinding"
joyeecheung Jan 11, 2019
7aeec97
Revert "lib: remove internalBinding('config').pendingDeprecation"
joyeecheung Jan 11, 2019
48dfda7
Revert "os: move process.binding('os') to internalBinding"
joyeecheung Jan 11, 2019
abfde34
Revert "lib: remove unused NativeModule/NativeModule wraps"
joyeecheung Jan 11, 2019
c5b2c31
Revert "src,lib: make process.binding('config') internal"
joyeecheung Jan 11, 2019
fb6f2f2
Revert "lib: remove duplicated noop function"
joyeecheung Jan 11, 2019
106b299
fs: make process.binding('fs') internal
Aug 23, 2018
9a5984d
src: use NativeModuleLoader to compile all the bootstrappers
joyeecheung Nov 26, 2018
373bbe7
lib: remove duplicated noop function
ZYSzys Dec 1, 2018
b6afa46
src,lib: make process.binding('config') internal
Oct 8, 2018
5bc4592
lib: remove unused NativeModule/NativeModule wraps
joyeecheung Dec 8, 2018
e05e5b3
inspector: move process.binding to internalBinding
BeniCheni Dec 10, 2018
181d03a
os: move process.binding('os') to internalBinding
briete Dec 17, 2018
4cb9036
lib: remove internalBinding('config').pendingDeprecation
joyeecheung Dec 11, 2018
7d90f03
lib: expose all type checks from the internal types module
BridgeAR Dec 20, 2018
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
8 changes: 7 additions & 1 deletion doc/api/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ changes:
pr-url: https://github.com/nodejs/node/pull/19372
description: The `Console` constructor now supports an `options` argument,
and the `colorMode` option was introduced.
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/24978
description: The `inspectOptions` option is introduced.
-->

* `options` {Object}
Expand All @@ -98,8 +101,11 @@ changes:
* `colorMode` {boolean|string} Set color support for this `Console` instance.
Setting to `true` enables coloring while inspecting values, setting to
`'auto'` will make color support depend on the value of the `isTTY` property
and the value returned by `getColorDepth()` on the respective stream.
and the value returned by `getColorDepth()` on the respective stream. This
option can not be used, if `inspectOptions.colors` is set as well.
**Default:** `'auto'`.
* `inspectOptions` {Object} Specifies options that are passed along to
[`util.inspect()`][].

Creates a new `Console` with one or two writable stream instances. `stdout` is a
writable stream to print log or info output. `stderr` is used for warning or
Expand Down
42 changes: 28 additions & 14 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,12 @@ is set for the `Http2Stream`.
`http2.connect()` was passed a URL that uses any protocol other than `http:` or
`https:`.

<a id="ERR_INCOMPATIBLE_OPTION_PAIR"></a>
### ERR_INCOMPATIBLE_OPTION_PAIR

An option pair is incompatible with each other and can not be used at the same
time.

<a id="ERR_INSPECTOR_ALREADY_CONNECTED"></a>
### ERR_INSPECTOR_ALREADY_CONNECTED

Expand Down Expand Up @@ -1804,20 +1810,6 @@ An attempt was made to load a module with an unknown or unsupported format.
An invalid or unknown process signal was passed to an API expecting a valid
signal (such as [`subprocess.kill()`][]).

<a id="ERR_UNKNOWN_STDIN_TYPE"></a>
### ERR_UNKNOWN_STDIN_TYPE

An attempt was made to launch a Node.js process with an unknown `stdin` file
type. This error is usually an indication of a bug within Node.js itself,
although it is possible for user code to trigger it.

<a id="ERR_UNKNOWN_STREAM_TYPE"></a>
### ERR_UNKNOWN_STREAM_TYPE

An attempt was made to launch a Node.js process with an unknown `stdout` or
`stderr` file type. This error is usually an indication of a bug within Node.js
itself, although it is possible for user code to trigger it.

<a id="ERR_V8BREAKITERATOR"></a>
### ERR_V8BREAKITERATOR

Expand Down Expand Up @@ -2074,6 +2066,28 @@ kind of internal Node.js error that should not typically be triggered by user
code. Instances of this error point to an internal bug within the Node.js
binary itself.

<a id="ERR_UNKNOWN_STDIN_TYPE"></a>
### ERR_UNKNOWN_STDIN_TYPE
<!-- YAML
added: v8.0.0
removed: REPLACEME
-->

An attempt was made to launch a Node.js process with an unknown `stdin` file
type. This error is usually an indication of a bug within Node.js itself,
although it is possible for user code to trigger it.

<a id="ERR_UNKNOWN_STREAM_TYPE"></a>
### ERR_UNKNOWN_STREAM_TYPE
<!-- YAML
added: v8.0.0
removed: REPLACEME
-->

An attempt was made to launch a Node.js process with an unknown `stdout` or
`stderr` file type. This error is usually an indication of a bug within Node.js
itself, although it is possible for user code to trigger it.

<a id="ERR_VALUE_OUT_OF_RANGE"></a>
### ERR_VALUE_OUT_OF_RANGE
<!-- YAML
Expand Down
3 changes: 3 additions & 0 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ stream.write('With ES6');
<!-- YAML
added: v0.3.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/25006
description: ArrayBuffers now also show their binary contents.
- version: v11.5.0
pr-url: https://github.com/nodejs/node/pull/24852
description: The `getters` option is supported now.
Expand Down
8 changes: 3 additions & 5 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Agent(options) {
this.defaultPort = 80;
this.protocol = 'http:';

this.options = util._extend({}, options);
this.options = { ...options };

// Don't confuse net and make it think that we're connecting to a pipe
this.options.path = null;
Expand Down Expand Up @@ -146,8 +146,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
};
}

options = util._extend({}, options);
util._extend(options, this.options);
options = { ...options, ...this.options };
if (options.socketPath)
options.path = options.socketPath;

Expand Down Expand Up @@ -194,8 +193,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
};

Agent.prototype.createSocket = function createSocket(req, options, cb) {
options = util._extend({}, options);
util._extend(options, this.options);
options = { ...options, ...this.options };
if (options.socketPath)
options.path = options.socketPath;

Expand Down
6 changes: 3 additions & 3 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ function ClientRequest(input, options, cb) {

if (typeof options === 'function') {
cb = options;
options = null;
options = input || {};
} else {
options = Object.assign(input || {}, options);
}

options = util._extend(input || {}, options || {});

var agent = options.agent;
var defaultAgent = options._defaultAgent || Agent.globalAgent;
if (agent === false) {
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function Server(options, requestListener) {
requestListener = options;
options = {};
} else if (options == null || typeof options === 'object') {
options = util._extend({}, options);
options = { ...options };
}

this[kIncomingMessage] = options.IncomingMessage || IncomingMessage;
Expand Down
18 changes: 9 additions & 9 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,22 +1108,22 @@ function SNICallback(servername, callback) {
//
//
function normalizeConnectArgs(listArgs) {
var args = net._normalizeArgs(listArgs);
var options = args[0];
var cb = args[1];
const args = net._normalizeArgs(listArgs);
const options = args[0];
const cb = args[1];

// If args[0] was options, then normalize dealt with it.
// If args[0] is port, or args[0], args[1] is host, port, we need to
// find the options and merge them in, normalize's options has only
// the host/port/path args that it knows about, not the tls options.
// This means that options.host overrides a host arg.
if (listArgs[1] !== null && typeof listArgs[1] === 'object') {
util._extend(options, listArgs[1]);
Object.assign(options, listArgs[1]);
} else if (listArgs[2] !== null && typeof listArgs[2] === 'object') {
util._extend(options, listArgs[2]);
Object.assign(options, listArgs[2]);
}

return (cb) ? [options, cb] : [options];
return cb ? [options, cb] : [options];
}

function onConnectSecure() {
Expand Down Expand Up @@ -1204,14 +1204,14 @@ exports.connect = function connect(...args) {
'certificate verification.');
}

var defaults = {
options = {
rejectUnauthorized: !allowUnauthorized,
ciphers: tls.DEFAULT_CIPHERS,
checkServerIdentity: tls.checkServerIdentity,
minDHSize: 1024
minDHSize: 1024,
...options
};

options = util._extend(defaults, options || {});
if (!options.keepAlive)
options.singleUse = true;

Expand Down
30 changes: 25 additions & 5 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,30 @@ const {
kMaxLength,
kStringMaxLength
} = internalBinding('buffer');
const { isAnyArrayBuffer } = internalBinding('types');
const {
getOwnNonIndexProperties,
propertyFilter: {
ALL_PROPERTIES,
ONLY_ENUMERABLE
}
} = internalBinding('util');
const {
customInspectSymbol,
isInsideNodeModules,
normalizeEncoding,
kIsEncodingSymbol
} = require('internal/util');
const {
isAnyArrayBuffer,
isArrayBufferView,
isUint8Array
} = require('internal/util/types');

const {
pendingDeprecation
} = internalBinding('config');
formatProperty,
kObjectType
} = require('internal/util/inspect');

const {
ERR_BUFFER_OUT_OF_BOUNDS,
ERR_OUT_OF_RANGE,
Expand Down Expand Up @@ -138,7 +148,7 @@ const bufferWarning = 'Buffer() is deprecated due to security and usability ' +
function showFlaggedDeprecation() {
if (bufferWarningAlreadyEmitted ||
++nodeModulesCheckCounter > 10000 ||
(!pendingDeprecation &&
(!require('internal/options').getOptionValue('--pending-deprecation') &&
isInsideNodeModules())) {
// We don't emit a warning, because we either:
// - Already did so, or
Expand Down Expand Up @@ -670,10 +680,20 @@ Buffer.prototype.equals = function equals(otherBuffer) {
Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
const max = exports.INSPECT_MAX_BYTES;
const actualMax = Math.min(max, this.length);
let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
const remaining = this.length - max;
let str = this.hexSlice(0, actualMax).replace(/(.{2})/g, '$1 ').trim();
if (remaining > 0)
str += ` ... ${remaining} more byte${remaining > 1 ? 's' : ''}`;
// Inspect special properties as well, if possible.
if (ctx) {
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
str += getOwnNonIndexProperties(this, filter).reduce((str, key) => {
// Using `formatProperty()` expects an indentationLvl to be set.
ctx.indentationLvl = 0;
str += `, ${formatProperty(ctx, this, recurseTimes, key, kObjectType)}`;
return str;
}, '');
}
return `<${this.constructor.name} ${str}>`;
};
Buffer.prototype.inspect = Buffer.prototype[customInspectSymbol];
Expand Down
35 changes: 19 additions & 16 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ exports.fork = function fork(modulePath /* , args, options */) {
throw new ERR_INVALID_ARG_VALUE(`arguments[${pos}]`, arguments[pos]);
}

options = util._extend({}, arguments[pos++]);
options = { ...arguments[pos++] };
}

// Prepare arguments for fork:
Expand Down Expand Up @@ -176,28 +176,20 @@ Object.defineProperty(exports.exec, util.promisify.custom, {
});

exports.execFile = function execFile(file /* , args, options, callback */) {
var args = [];
var callback;
var options = {
encoding: 'utf8',
timeout: 0,
maxBuffer: 200 * 1024,
killSignal: 'SIGTERM',
cwd: null,
env: null,
shell: false
};
let args = [];
let callback;
let options;

// Parse the optional positional parameters.
var pos = 1;
let pos = 1;
if (pos < arguments.length && Array.isArray(arguments[pos])) {
args = arguments[pos++];
} else if (pos < arguments.length && arguments[pos] == null) {
pos++;
}

if (pos < arguments.length && typeof arguments[pos] === 'object') {
util._extend(options, arguments[pos++]);
options = arguments[pos++];
} else if (pos < arguments.length && arguments[pos] == null) {
pos++;
}
Expand All @@ -210,6 +202,17 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
throw new ERR_INVALID_ARG_VALUE('args', arguments[pos]);
}

options = {
encoding: 'utf8',
timeout: 0,
maxBuffer: 200 * 1024,
killSignal: 'SIGTERM',
cwd: null,
env: null,
shell: false,
...options
};

// Validate the timeout, if present.
validateTimeout(options.timeout);

Expand Down Expand Up @@ -580,15 +583,15 @@ function spawnSync(file, args, options) {
options.stdio = _validateStdio(options.stdio || 'pipe', true).stdio;

if (options.input) {
var stdin = options.stdio[0] = util._extend({}, options.stdio[0]);
var stdin = options.stdio[0] = { ...options.stdio[0] };
stdin.input = options.input;
}

// We may want to pass data in on any given fd, ensure it is a valid buffer
for (var i = 0; i < options.stdio.length; i++) {
var input = options.stdio[i] && options.stdio[i].input;
if (input != null) {
var pipe = options.stdio[i] = util._extend({}, options.stdio[i]);
var pipe = options.stdio[i] = { ...options.stdio[i] };
if (isArrayBufferView(input)) {
pipe.input = input;
} else if (typeof input === 'string') {
Expand Down
Loading