From 18d725f8040a45743a60f6c0dcdf8e73d0cdb3f3 Mon Sep 17 00:00:00 2001 From: Daeyeon Jeong Date: Fri, 8 Jul 2022 07:53:48 +0900 Subject: [PATCH] fixup: remove the range restriction Signed-off-by: Daeyeon Jeong daeyeon.dev@gmail.com --- doc/api/process.md | 2 +- lib/internal/process/per_thread.js | 2 +- .../parallel/test-process-exit-code-validation.js | 15 ++------------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index 95cbc7455d9449..4b48a6590b7d2a 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1716,7 +1716,7 @@ that started the Node.js process. Symbolic links, if any, are resolved. added: v0.1.13 --> -* `code` {integer} The exit code in the range `0` – `255`. **Default:** `0`. +* `code` {integer} The exit code. **Default:** `0`. The `process.exit()` method instructs Node.js to terminate the process synchronously with an exit status of `code`. If `code` is omitted, exit uses diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 7e001469eaf814..fe3b6462d47495 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -183,7 +183,7 @@ function wrapProcessMethods(binding) { process.off('exit', handleProcessExit); if (code !== null && code !== undefined) { - validateInteger(code, 'code', 0, 255); + validateInteger(code, 'code'); process.exitCode = code; } diff --git a/test/parallel/test-process-exit-code-validation.js b/test/parallel/test-process-exit-code-validation.js index caba04d998f3ce..1f8aa814c66855 100644 --- a/test/parallel/test-process-exit-code-validation.js +++ b/test/parallel/test-process-exit-code-validation.js @@ -4,25 +4,14 @@ require('../common'); const { strictEqual } = require('node:assert'); const isParent = () => process.argv[2] === undefined; -const invalid_type_samples = ['', '0', {}, [], true, false]; -const out_of_range_samples = [-1, 256]; -const args = [...invalid_type_samples, ...out_of_range_samples]; +const args = ['', '0', {}, [], true, false]; if (isParent()) { const { spawn } = require('node:child_process'); // Test the samples. strictEqual( - invalid_type_samples.every( - (v) => typeof v !== 'number' && v !== null && v !== undefined, - ), - true, - ); - - strictEqual( - out_of_range_samples.every( - (v) => typeof v == 'number' && (v < 0 || v > 255), - ), + args.every((v) => typeof v !== 'number' && v !== null && v !== undefined), true, );