File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed
packages/pg-connection-string Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -68,23 +68,26 @@ function parse(str) {
68
68
config . ssl = { }
69
69
}
70
70
71
- try {
72
- if ( config . sslcert ) {
73
- const fs = require ( 'fs' )
74
- config . ssl . cert = fs . readFileSync ( config . sslcert ) . toString ( )
71
+ let fs
72
+ if ( config . sslcert || config . sslkey || config . sslrootcert ) {
73
+ try {
74
+ // Only try to load fs if we expect to read from the disk
75
+ fs = require ( 'fs' )
76
+ } catch ( e ) {
77
+ throw new Error ( 'filesystem not supported' )
75
78
}
79
+ }
76
80
77
- if ( config . sslkey ) {
78
- const fs = require ( 'fs' )
79
- config . ssl . key = fs . readFileSync ( config . sslkey ) . toString ( )
80
- }
81
+ if ( config . sslcert ) {
82
+ config . ssl . cert = fs . readFileSync ( config . sslcert ) . toString ( )
83
+ }
81
84
82
- if ( config . sslrootcert ) {
83
- const fs = require ( 'fs' )
84
- config . ssl . ca = fs . readFileSync ( config . sslrootcert ) . toString ( )
85
- }
86
- } catch ( e ) {
87
- throw new Error ( 'filesystem not supported' )
85
+ if ( config . sslkey ) {
86
+ config . ssl . key = fs . readFileSync ( config . sslkey ) . toString ( )
87
+ }
88
+
89
+ if ( config . sslrootcert ) {
90
+ config . ssl . ca = fs . readFileSync ( config . sslrootcert ) . toString ( )
88
91
}
89
92
90
93
switch ( config . sslmode ) {
You can’t perform that action at this time.
0 commit comments