@@ -12,6 +12,7 @@ use eyre::{eyre, WrapErr};
1212use owo_colors:: OwoColorize ;
1313use serde:: { Deserialize , Serialize } ;
1414use std:: collections:: { BTreeMap , HashMap } ;
15+ use std:: env:: consts:: EXE_SUFFIX ;
1516use std:: ffi:: OsString ;
1617use std:: fmt:: { self , Debug , Display , Formatter } ;
1718use std:: io:: ErrorKind ;
@@ -334,55 +335,37 @@ impl PgConfig {
334335
335336 pub fn postmaster_path ( & self ) -> eyre:: Result < PathBuf > {
336337 let mut path = self . bin_dir ( ) ?;
337- #[ cfg( not( target_os = "windows" ) ) ]
338- path. push ( "postgres" ) ;
339- #[ cfg( target_os = "windows" ) ]
340- path. push ( "postgres.exe" ) ;
338+ path. push ( format ! ( "postgres{EXE_SUFFIX}" ) ) ;
341339 Ok ( path)
342340 }
343341
344342 pub fn initdb_path ( & self ) -> eyre:: Result < PathBuf > {
345343 let mut path = self . bin_dir ( ) ?;
346- #[ cfg( not( target_os = "windows" ) ) ]
347- path. push ( "initdb" ) ;
348- #[ cfg( target_os = "windows" ) ]
349- path. push ( "initdb.exe" ) ;
344+ path. push ( format ! ( "initdb{EXE_SUFFIX}" ) ) ;
350345 Ok ( path)
351346 }
352347
353348 pub fn createdb_path ( & self ) -> eyre:: Result < PathBuf > {
354349 let mut path = self . bin_dir ( ) ?;
355- #[ cfg( not( target_os = "windows" ) ) ]
356- path. push ( "createdb" ) ;
357- #[ cfg( target_os = "windows" ) ]
358- path. push ( "createdb.exe" ) ;
350+ path. push ( format ! ( "createdb{EXE_SUFFIX}" ) ) ;
359351 Ok ( path)
360352 }
361353
362354 pub fn dropdb_path ( & self ) -> eyre:: Result < PathBuf > {
363355 let mut path = self . bin_dir ( ) ?;
364- #[ cfg( not( target_os = "windows" ) ) ]
365- path. push ( "dropdb" ) ;
366- #[ cfg( target_os = "windows" ) ]
367- path. push ( "dropdb.exe" ) ;
356+ path. push ( format ! ( "dropdb{EXE_SUFFIX}" ) ) ;
368357 Ok ( path)
369358 }
370359
371360 pub fn pg_ctl_path ( & self ) -> eyre:: Result < PathBuf > {
372361 let mut path = self . bin_dir ( ) ?;
373- #[ cfg( not( target_os = "windows" ) ) ]
374- path. push ( "pg_ctl" ) ;
375- #[ cfg( target_os = "windows" ) ]
376- path. push ( "pg_ctl.exe" ) ;
362+ path. push ( format ! ( "pg_ctl{EXE_SUFFIX}" ) ) ;
377363 Ok ( path)
378364 }
379365
380366 pub fn psql_path ( & self ) -> eyre:: Result < PathBuf > {
381367 let mut path = self . bin_dir ( ) ?;
382- #[ cfg( not( target_os = "windows" ) ) ]
383- path. push ( "psql" ) ;
384- #[ cfg( target_os = "windows" ) ]
385- path. push ( "psql.exe" ) ;
368+ path. push ( format ! ( "psql{EXE_SUFFIX}" ) ) ;
386369 Ok ( path)
387370 }
388371
0 commit comments