File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ const { IterableWeakMap } = require('internal/util/iterable_weak_map');
29
29
const {
30
30
normalizeReferrerURL,
31
31
} = require ( 'internal/modules/cjs/helpers' ) ;
32
+ const { validateBoolean } = require ( 'internal/validators' ) ;
32
33
// Since the CJS module cache is mutable, which leads to memory leaks when
33
34
// modules are deleted, we use a WeakMap so that the source map cache will
34
35
// be purged automatically:
@@ -47,6 +48,8 @@ function getSourceMapsEnabled() {
47
48
}
48
49
49
50
function setSourceMapsEnabled ( val ) {
51
+ validateBoolean ( val , 'val' ) ;
52
+
50
53
const {
51
54
setSourceMapsEnabled,
52
55
setPrepareStackTraceCallback
@@ -58,7 +61,7 @@ function setSourceMapsEnabled(val) {
58
61
} = require ( 'internal/source_map/prepare_stack_trace' ) ;
59
62
setPrepareStackTraceCallback ( prepareStackTrace ) ;
60
63
} else if ( sourceMapsEnabled !== undefined ) {
61
- // Set prepare stack trace callback only when disabling source maps.
64
+ // Reset prepare stack trace callback only when disabling source maps.
62
65
const {
63
66
prepareStackTrace,
64
67
} = require ( 'internal/errors' ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ require ( '../common' ) ;
3
+ const assert = require ( 'assert' ) ;
4
+
5
+ const unexpectedValues = [
6
+ undefined ,
7
+ null ,
8
+ 1 ,
9
+ { } ,
10
+ ( ) => { } ,
11
+ ] ;
12
+ for ( const it of unexpectedValues ) {
13
+ assert . throws ( ( ) => {
14
+ process . setSourceMapsEnabled ( it ) ;
15
+ } , / E R R _ I N V A L I D _ A R G _ T Y P E / ) ;
16
+ }
You can’t perform that action at this time.
0 commit comments