From 7d1f4f849cecba47fff39f5a0be0e1fe8711af8a Mon Sep 17 00:00:00 2001 From: sapphi-red Date: Sat, 28 Jan 2023 21:07:06 +0900 Subject: [PATCH] lib: add api to detect whether source-maps are enabled Add `process.getSourceMapsEnabled` to detect whether source-maps are enabled. Fixes: https://github.com/nodejs/node/issues/46304 --- doc/api/process.md | 13 +++++++++++++ lib/internal/process/pre_execution.js | 6 +++--- lib/internal/source_map/source_map_cache.js | 9 ++++++--- test/message/source_map_disabled_by_api.js | 4 ++++ test/message/source_map_enabled_by_api.js | 4 ++++ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index 4a4a60c2735d98..842e83b8f9bb62 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -2009,6 +2009,19 @@ if (process.getgroups) { This function is only available on POSIX platforms (i.e. not Windows or Android). +## `process.getSourceMapsEnabled()` + + + +> Stability: 1 - Experimental + +* Returns: {boolean} + +The `process.getSourceMapsEnabled()` method returns whether the +[Source Map v3][Source Map] support for stack traces is enabled. + ## `process.getuid()`