lib: make console writable and non-enumerable

According to the standard the property descriptor of console
should be writable and non-enumerable.

PR-URL: https://github.com/nodejs/node/pull/17708
Fixes: https://github.com/nodejs/node/issues/11805
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
This commit is contained in:
Ruben Bridgewater 2017-12-16 04:29:40 -02:00
parent f054855bbf
commit e99ae7764d
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
2 changed files with 3 additions and 5 deletions

View File

@ -321,10 +321,8 @@
const wrappedConsole = NativeModule.require('console');
Object.defineProperty(global, 'console', {
configurable: true,
enumerable: true,
get() {
return wrappedConsole;
}
enumerable: false,
value: wrappedConsole
});
setupInspector(originalConsole, wrappedConsole, Module);
}

View File

@ -16,7 +16,7 @@ function a() {
try {
return a();
} catch (e) {
compiledConsole = consoleDescriptor.get();
compiledConsole = consoleDescriptor.value;
if (compiledConsole.log) {
// Using `console.log` itself might not succeed yet, but the code for it
// has been compiled.