File tree 5 files changed +244
-326
lines changed
5 files changed +244
-326
lines changed Original file line number Diff line number Diff line change @@ -52,15 +52,20 @@ async function main () {
52
52
}
53
53
54
54
if ( ! argv . useSpawnWrap ) {
55
- const { preloadAppend, propagateEnv } = require ( 'node-preload' )
56
-
57
- nyc . require . forEach ( requireModule => {
58
- const mod = resolveFrom . silent ( nyc . cwd , requireModule ) || requireModule
59
- preloadAppend ( mod )
55
+ const requireModules = [
56
+ require . resolve ( '../lib/register-env.js' ) ,
57
+ ...nyc . require . map ( mod => resolveFrom . silent ( nyc . cwd , mod ) || mod )
58
+ ]
59
+ const preloadList = require ( 'node-preload' )
60
+ preloadList . push (
61
+ ...requireModules ,
62
+ require . resolve ( '../lib/wrap.js' )
63
+ )
64
+
65
+ Object . assign ( process . env , env )
66
+ requireModules . forEach ( mod => {
60
67
require ( mod )
61
68
} )
62
- preloadAppend ( require . resolve ( '../lib/wrap.js' ) )
63
- Object . assign ( propagateEnv , env )
64
69
}
65
70
66
71
if ( argv . all ) {
Original file line number Diff line number Diff line change @@ -365,8 +365,8 @@ class NYC {
365
365
// This is a bug with the spawn-wrap method where
366
366
// we cannot force propagation of NYC_PROCESS_ID.
367
367
if ( ! this . config . useSpawnWrap ) {
368
- const { propagateEnv } = require ( 'node-preload ' )
369
- propagateEnv . NYC_PROCESS_ID = this . processInfo . uuid
368
+ const updateVariable = require ( './lib/register-env.js ' )
369
+ updateVariable ( ' NYC_PROCESS_ID' )
370
370
}
371
371
this . _addRequireHooks ( )
372
372
this . _wrapExit ( )
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const processOnSpawn = require ( 'process-on-spawn' )
4
+
5
+ const envToCopy = { }
6
+
7
+ processOnSpawn . addListener ( ( { env } ) => {
8
+ Object . assign ( env , envToCopy )
9
+ } )
10
+
11
+ const copyAtLoad = [
12
+ 'NYC_CONFIG' ,
13
+ 'NYC_CWD' ,
14
+ 'NYC_PROCESS_ID' ,
15
+ 'BABEL_DISABLE_CACHE' ,
16
+ 'NYC_PROCESS_ID'
17
+ ]
18
+
19
+ for ( const env of copyAtLoad ) {
20
+ if ( env in process . env ) {
21
+ envToCopy [ env ] = process . env [ env ]
22
+ }
23
+ }
24
+
25
+ module . exports = function updateVariable ( envName ) {
26
+ envToCopy [ envName ] = process . env [ envName ]
27
+ }
You can’t perform that action at this time.
0 commit comments