Skip to content

Commit 8941498

Browse files
committed
refactor: improve Node.js 18 deprecation warning check
- Extract deprecation warning logic into shouldShowDeprecationWarning function - Replace startsWith check with regex pattern for more accurate version matching - Add explicit undefined check for process.version
1 parent eadbaf9 commit 8941498

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ export const createClient = <
4141
}
4242

4343
// Check for Node.js 18 deprecation
44-
if (
45-
typeof window === 'undefined' &&
46-
typeof process !== 'undefined' &&
47-
process.version &&
48-
process.version.startsWith('v18')
49-
) {
44+
function shouldShowDeprecationWarning(): boolean {
45+
return (
46+
typeof window === 'undefined' &&
47+
typeof process !== 'undefined' &&
48+
process.version !== undefined &&
49+
/^v18\./.test(process.version)
50+
)
51+
}
52+
53+
if (shouldShowDeprecationWarning()) {
5054
console.warn(
5155
`⚠️ Node.js 18 is deprecated and will no longer be supported in future versions of @supabase/supabase-js. ` +
5256
`Please upgrade to Node.js 20 or later. ` +

0 commit comments

Comments
 (0)