chore: Use formatter for robustness (#15006)
authorElliott Johnson <elliott.johnson@vercel.com>
Wed, 3 Dec 2025 04:43:09 +0000 (21:43 -0700)
committerGitHub <noreply@github.com>
Wed, 3 Dec 2025 04:43:09 +0000 (12:43 +0800)
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
packages/adapter-vercel/utils.js

index d7723e1a2af93a8664d6e97a7ea1777ac4e309b6..55fae7e358dec6d71889dc805c9bbe5667d4e515 100644 (file)
@@ -121,6 +121,7 @@ export function resolve_runtime(default_key, override_key) {
 }
 
 const valid_node_versions = [20, 22, 24];
+const formatter = new Intl.ListFormat('en', { type: 'disjunction' });
 
 /** @returns {RuntimeKey} */
 function get_default_runtime() {
@@ -131,7 +132,7 @@ function get_default_runtime() {
 
        if (!valid_node_versions.includes(major)) {
                throw new Error(
-                       `Unsupported Node.js version: ${process.version}. Please use Node ${valid_node_versions.slice(0, -1).join(', ')} or ${valid_node_versions.at(-1)} to build your project, or explicitly specify a runtime in your adapter configuration.`
+                       `Unsupported Node.js version: ${process.version}. Please use Node ${formatter.format(valid_node_versions.map((v) => `${v}`))} to build your project, or explicitly specify a runtime in your adapter configuration.`
                );
        }