1
1
'use strict' ;
2
- /* eslint-disable max-len */
3
2
4
3
require ( '../common' ) ;
5
4
const assert = require ( 'assert' ) ;
6
- const spawn = require ( 'child_process' ) . spawn ;
7
-
8
- /* For the moment we are not going to support setting the timezone via the
9
- * environment variables. The problem is that various V8 platform backends
10
- * deal with timezone in different ways. The windows platform backend caches
11
- * the timezone value while the Linux one hits libc for every query.
12
-
13
- https://github.com/joyent/node/blob/08782931205bc4f6d28102ebc29fd806e8ccdf1f/deps/v8/src/platform-linux.cc#L339-345
14
- https://github.com/joyent/node/blob/08782931205bc4f6d28102ebc29fd806e8ccdf1f/deps/v8/src/platform-win32.cc#L590-596
15
-
16
- // first things first, set the timezone; see tzset(3)
17
- process.env.TZ = 'Europe/Amsterdam';
18
-
19
- // time difference between Greenwich and Amsterdam is +2 hours in the summer
20
- date = new Date('Fri, 10 Sep 1982 03:15:00 GMT');
21
- assert.equal(3, date.getUTCHours());
22
- assert.equal(5, date.getHours());
23
- */
24
-
25
5
26
6
// changes in environment should be visible to child processes
27
- if ( process . argv [ 2 ] == 'you-are-the-child' ) {
28
- // failed assertion results in process exiting with status code 1
7
+ if ( process . argv [ 2 ] === 'you-are-the-child' ) {
29
8
assert . strictEqual ( false , 'NODE_PROCESS_ENV_DELETED' in process . env ) ;
30
9
assert . strictEqual ( '42' , process . env . NODE_PROCESS_ENV ) ;
31
10
assert . strictEqual ( 'asdf' , process . env . hasOwnProperty ) ;
32
- var hasOwnProperty = Object . prototype . hasOwnProperty ;
11
+ const hasOwnProperty = Object . prototype . hasOwnProperty ;
33
12
const has = hasOwnProperty . call ( process . env , 'hasOwnProperty' ) ;
34
13
assert . strictEqual ( true , has ) ;
35
14
process . exit ( 0 ) ;
36
- } else {
37
- assert . strictEqual ( Object . prototype . hasOwnProperty , process . env . hasOwnProperty ) ;
15
+ }
16
+
17
+ {
18
+ const spawn = require ( 'child_process' ) . spawn ;
19
+
20
+ assert . strictEqual ( Object . prototype . hasOwnProperty ,
21
+ process . env . hasOwnProperty ) ;
38
22
const has = process . env . hasOwnProperty ( 'hasOwnProperty' ) ;
39
23
assert . strictEqual ( false , has ) ;
40
24
@@ -49,17 +33,37 @@ if (process.argv[2] == 'you-are-the-child') {
49
33
delete process . env . NODE_PROCESS_ENV_DELETED ;
50
34
assert . strictEqual ( false , 'NODE_PROCESS_ENV_DELETED' in process . env ) ;
51
35
52
- var child = spawn ( process . argv [ 0 ] , [ process . argv [ 1 ] , 'you-are-the-child' ] ) ;
36
+ const child = spawn ( process . argv [ 0 ] , [ process . argv [ 1 ] , 'you-are-the-child' ] ) ;
53
37
child . stdout . on ( 'data' , function ( data ) { console . log ( data . toString ( ) ) ; } ) ;
54
38
child . stderr . on ( 'data' , function ( data ) { console . log ( data . toString ( ) ) ; } ) ;
55
39
child . on ( 'exit' , function ( statusCode ) {
56
- if ( statusCode != 0 ) {
40
+ if ( statusCode !== 0 ) {
57
41
process . exit ( statusCode ) ; // failed assertion in child process
58
42
}
59
43
} ) ;
60
44
}
61
45
46
+
62
47
// delete should return true except for non-configurable properties
63
48
// https://github.com/nodejs/node/issues/7960
64
49
delete process . env . NON_EXISTING_VARIABLE ;
65
50
assert . strictEqual ( true , delete process . env . NON_EXISTING_VARIABLE ) ;
51
+
52
+ /* eslint-disable max-len */
53
+ /* For the moment we are not going to support setting the timezone via the
54
+ * environment variables. The problem is that various V8 platform backends
55
+ * deal with timezone in different ways. The windows platform backend caches
56
+ * the timezone value while the Linux one hits libc for every query.
57
+
58
+ https://github.com/joyent/node/blob/08782931205bc4f6d28102ebc29fd806e8ccdf1f/deps/v8/src/platform-linux.cc#L339-345
59
+ https://github.com/joyent/node/blob/08782931205bc4f6d28102ebc29fd806e8ccdf1f/deps/v8/src/platform-win32.cc#L590-596
60
+
61
+ // set the timezone; see tzset(3)
62
+ process.env.TZ = 'Europe/Amsterdam';
63
+
64
+ // time difference between Greenwich and Amsterdam is +2 hours in the summer
65
+ date = new Date('Fri, 10 Sep 1982 03:15:00 GMT');
66
+ assert.equal(3, date.getUTCHours());
67
+ assert.equal(5, date.getHours());
68
+ */
69
+ /* eslint-enable max-len */
0 commit comments