node/lib/internal/options.js
Shelley Vohr c23d2fd3f8
src: allow embedders to disable esm loader
PR-URL: https://github.com/nodejs/node/pull/34060
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2020-06-29 09:12:11 -07:00

37 lines
898 B
JavaScript

'use strict';
const { getOptions, shouldNotRegisterESMLoader } = internalBinding('options');
const { options, aliases } = getOptions();
let warnOnAllowUnauthorized = true;
function getOptionValue(option) {
const result = options.get(option);
if (!result) {
return undefined;
}
return result.value;
}
function getAllowUnauthorized() {
const allowUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0';
if (allowUnauthorized && warnOnAllowUnauthorized) {
warnOnAllowUnauthorized = false;
process.emitWarning(
'Setting the NODE_TLS_REJECT_UNAUTHORIZED ' +
'environment variable to \'0\' makes TLS connections ' +
'and HTTPS requests insecure by disabling ' +
'certificate verification.');
}
return allowUnauthorized;
}
module.exports = {
options,
aliases,
getOptionValue,
getAllowUnauthorized,
shouldNotRegisterESMLoader
};