GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: add api to detect whether source-maps are enabled · nodejs/node@17246be

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • process.md
  • lib/internal/bootstrap
    • node.js
  • test/fixtures/source-map/output
    • source_map_disabled_by_api.js
    • source_map_enabled_by_api.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/process.md‎

Copy file name to clipboardExpand all lines: doc/api/process.md
+13Lines changed: 13 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3458,6 +3458,19 @@ throw an error.
34583458
Using this function is mutually exclusive with using the deprecated
34593459
[`domain`][] built-in module.
34603460
3461+
## `process.sourceMapsEnabled`
3462+
3463+
<!-- YAML
3464+
added: REPLACEME
3465+
-->
3466+
3467+
> Stability: 1 - Experimental
3468+
3469+
* {boolean}
3470+
3471+
The `process.sourceMapsEnabled` property returns whether the
3472+
[Source Map v3][Source Map] support for stack traces is enabled.
3473+
34613474
## `process.stderr`
34623475
34633476
* {Stream}
Collapse file

‎lib/internal/bootstrap/node.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/node.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,22 @@ process.emitWarning = emitWarning;
359359

360360
{
361361
const {
362+
getSourceMapsEnabled,
362363
setSourceMapsEnabled,
363364
maybeCacheGeneratedSourceMap,
364365
} = require('internal/source_map/source_map_cache');
365366
const {
366367
setMaybeCacheGeneratedSourceMap,
367368
} = internalBinding('errors');
368369

370+
ObjectDefineProperty(process, 'sourceMapsEnabled', {
371+
__proto__: null,
372+
enumerable: true,
373+
configurable: true,
374+
get() {
375+
return getSourceMapsEnabled();
376+
},
377+
});
369378
process.setSourceMapsEnabled = setSourceMapsEnabled;
370379
// The C++ land calls back to maybeCacheGeneratedSourceMap()
371380
// when code is generated by user with eval() or new Function()
Collapse file

‎test/fixtures/source-map/output/source_map_disabled_by_api.js‎

Copy file name to clipboardExpand all lines: test/fixtures/source-map/output/source_map_disabled_by_api.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
'use strict';
44
require('../../../common');
5+
const assert = require('assert');
56
Error.stackTraceLimit = 5;
67

8+
assert.strictEqual(process.sourceMapsEnabled, true);
79
process.setSourceMapsEnabled(false);
10+
assert.strictEqual(process.sourceMapsEnabled, false);
811

912
try {
1013
require('../enclosing-call-site-min.js');
@@ -17,6 +20,7 @@ delete require.cache[require
1720

1821
// Re-enable.
1922
process.setSourceMapsEnabled(true);
23+
assert.strictEqual(process.sourceMapsEnabled, true);
2024

2125
try {
2226
require('../enclosing-call-site-min.js');
Collapse file

‎test/fixtures/source-map/output/source_map_enabled_by_api.js‎

Copy file name to clipboardExpand all lines: test/fixtures/source-map/output/source_map_enabled_by_api.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
'use strict';
22
require('../../../common');
3+
const assert = require('assert');
34
Error.stackTraceLimit = 5;
45

6+
assert.strictEqual(process.sourceMapsEnabled, false);
57
process.setSourceMapsEnabled(true);
8+
assert.strictEqual(process.sourceMapsEnabled, true);
69

710
try {
811
require('../enclosing-call-site-min.js');
@@ -14,6 +17,7 @@ delete require.cache[require
1417
.resolve('../enclosing-call-site-min.js')];
1518

1619
process.setSourceMapsEnabled(false);
20+
assert.strictEqual(process.sourceMapsEnabled, false);
1721

1822
try {
1923
require('../enclosing-call-site-min.js');

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.