Skip to content

Commit 8d7ace8

Browse files
authored
fix(pg): only guard process.env access when forcing native client
1 parent 43f2c27 commit 8d7ace8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/pg/lib/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ const PG = function (clientConstructor) {
3636

3737
let clientConstructor = Client
3838

39+
let forceNative = false
3940
try {
40-
if (process.env.NODE_PG_FORCE_NATIVE) {
41-
clientConstructor = require('./native')
42-
}
41+
forceNative = !!process.env.NODE_PG_FORCE_NATIVE
4342
} catch {
4443
// ignore, e.g., Deno without --allow-env
4544
}
4645

46+
if (forceNative) {
47+
clientConstructor = require('./native')
48+
}
49+
4750
module.exports = new PG(clientConstructor)
4851

4952
// lazy require native module...the native module may not have installed

0 commit comments

Comments
 (0)