Skip to content

Commit d4ad2fe

Browse files
committed
fixup: move the validation into process.exitCode
Signed-off-by: Daeyeon Jeong [email protected]
1 parent 704b025 commit d4ad2fe

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

lib/internal/bootstrap/node.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const {
4444
ArrayPrototypeFill,
4545
FunctionPrototypeCall,
4646
JSONParse,
47+
Number,
4748
ObjectDefineProperty,
4849
ObjectGetPrototypeOf,
4950
ObjectPreventExtensions,
@@ -60,6 +61,9 @@ const {
6061
deprecate,
6162
exposeInterface,
6263
} = require('internal/util');
64+
const {
65+
validateInteger,
66+
} = require('internal/validators');
6367

6468
setupProcessObject();
6569

@@ -69,6 +73,27 @@ setupBuffer();
6973
process.domain = null;
7074
process._exiting = false;
7175

76+
{
77+
let exitCode;
78+
ObjectDefineProperty(process, 'exitCode', {
79+
__proto__: null,
80+
get() {
81+
return exitCode;
82+
},
83+
set(code) {
84+
if (code !== null && code !== undefined) {
85+
validateInteger(
86+
typeof code === 'string' && code !== '' ? Number(code) : code,
87+
'code'
88+
);
89+
}
90+
exitCode = code;
91+
},
92+
enumerable: true,
93+
configurable: true,
94+
});
95+
}
96+
7297
// process.config is serialized config.gypi
7398
const nativeModule = internalBinding('native_module');
7499

lib/internal/process/per_thread.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const {
1313
ArrayPrototypeSplice,
1414
BigUint64Array,
1515
Float64Array,
16-
Number,
1716
NumberMAX_SAFE_INTEGER,
1817
ObjectFreeze,
1918
ReflectApply,
@@ -44,7 +43,6 @@ const {
4443
const format = require('internal/util/inspect').format;
4544
const {
4645
validateArray,
47-
validateInteger,
4846
validateNumber,
4947
validateObject,
5048
} = require('internal/validators');
@@ -184,10 +182,6 @@ function wrapProcessMethods(binding) {
184182
process.off('exit', handleProcessExit);
185183

186184
if (code !== null && code !== undefined) {
187-
validateInteger(
188-
typeof code === 'string' && code !== '' ? Number(code) : code,
189-
'code',
190-
);
191185
process.exitCode = code;
192186
}
193187

0 commit comments

Comments
 (0)