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

src: remove internalBinding('config').warningFile #24959

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 13 additions & 5 deletions lib/internal/process/warning.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
'use strict';

const config = internalBinding('config');
const prefix = `(${process.release.name}:${process.pid}) `;
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;

exports.setup = setupProcessWarnings;

let options;
function lazyOption(name) {
if (!options) {
options = require('internal/options');
}
return options.getOptionValue(name);
}

var cachedFd;
var acquiringFd = false;
function nop() {}
Expand Down Expand Up @@ -49,11 +56,11 @@ function onAcquired(message) {
};
}

function acquireFd(cb) {
function acquireFd(warningFile, cb) {
if (cachedFd === undefined && !acquiringFd) {
acquiringFd = true;
if (fs === null) fs = require('fs');
fs.open(config.warningFile, 'a', onOpen(cb));
fs.open(warningFile, 'a', onOpen(cb));
} else if (cachedFd !== undefined && !acquiringFd) {
cb(null, cachedFd);
} else {
Expand All @@ -62,8 +69,9 @@ function acquireFd(cb) {
}

function output(message) {
if (typeof config.warningFile === 'string') {
acquireFd(onAcquired(message));
const warningFile = lazyOption('--redirect-warnings');
if (warningFile) {
acquireFd(warningFile, onAcquired(message));
return;
}
writeOut(message);
Expand Down
5 changes: 0 additions & 5 deletions src/node_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ static void Initialize(Local<Object> target,
"bits",
Number::New(env->isolate(), 8 * sizeof(intptr_t)));

const std::string& warning_file = env->options()->redirect_warnings;
if (!warning_file.empty()) {
READONLY_STRING_PROPERTY(target, "warningFile", warning_file);
}

Local<Object> debug_options_obj = Object::New(isolate);
READONLY_PROPERTY(target, "debugOptions", debug_options_obj);

Expand Down