File tree 3 files changed +23
-1
lines changed
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,13 @@ added: v0.11.15
277
277
Data path for ICU (Intl object) data. Will extend linked-in data when compiled
278
278
with small-icu support.
279
279
280
+ ### ` NODE_PRESERVE_SYMLINKS=1 `
281
+ <!-- YAML
282
+ added: REPLACEME
283
+ -->
284
+
285
+ When set to ` 1 ` , instructs the module loader to preserve symbolic links when
286
+ resolving and caching modules.
280
287
281
288
### ` NODE_REPL_HISTORY=file `
282
289
<!-- YAML
Original file line number Diff line number Diff line change @@ -4188,6 +4188,11 @@ void Init(int* argc,
4188
4188
V8::SetFlagsFromString (NODE_V8_OPTIONS, sizeof (NODE_V8_OPTIONS) - 1 );
4189
4189
#endif
4190
4190
4191
+ // Allow for environment set preserving symlinks.
4192
+ if (auto preserve_symlinks = secure_getenv (" NODE_PRESERVE_SYMLINKS" )) {
4193
+ config_preserve_symlinks = (*preserve_symlinks == ' 1' );
4194
+ }
4195
+
4191
4196
// Parse a few arguments which are specific to Node.
4192
4197
int v8_argc;
4193
4198
const char ** v8_argv;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const path = require('path');
6
6
const fs = require ( 'fs' ) ;
7
7
const exec = require ( 'child_process' ) . exec ;
8
8
const spawn = require ( 'child_process' ) . spawn ;
9
+ const util = require ( 'util' ) ;
9
10
10
11
common . refreshTmpDir ( ) ;
11
12
@@ -53,7 +54,16 @@ function test() {
53
54
const node = process . execPath ;
54
55
const child = spawn ( node , [ '--preserve-symlinks' , linkScript ] ) ;
55
56
child . on ( 'close' , function ( code , signal ) {
56
- assert ( ! code ) ;
57
+ assert . strictEqual ( code , 0 ) ;
58
+ assert ( ! signal ) ;
59
+ } ) ;
60
+
61
+ // Also verify that symlinks works for setting preserve via env variables
62
+ const childEnv = spawn ( node , [ linkScript ] , {
63
+ env : util . _extend ( process . env , { NODE_PRESERVE_SYMLINKS : '1' } )
64
+ } ) ;
65
+ childEnv . on ( 'close' , function ( code , signal ) {
66
+ assert . strictEqual ( code , 0 ) ;
57
67
assert ( ! signal ) ;
58
68
} ) ;
59
69
}
You can’t perform that action at this time.
0 commit comments