@@ -21,17 +21,15 @@ import {
2121 ProfileAuthProvider ,
2222} from "./auth/AuthProvider" ;
2323import { FileUtils , UrlUtils } from "../utils" ;
24- import {
25- loadConfigFile ,
26- AuthType as SdkAuthType ,
27- } from "@databricks/databricks-sdk" ;
24+ import { AuthType as SdkAuthType } from "@databricks/databricks-sdk" ;
2825import { randomUUID } from "crypto" ;
2926import ini from "ini" ;
3027import { appendFile , copyFile } from "fs/promises" ;
3128import path from "path" ;
3229import os from "os" ;
3330import { createFile } from "fs-extra" ;
3431import { getDatabricksConfigFilePath } from "../utils/fileUtils" ;
32+ import { stat } from "node:fs/promises" ;
3533
3634interface AuthTypeQuickPickItem extends QuickPickItem {
3735 authType ?: SdkAuthType ;
@@ -388,7 +386,7 @@ export async function saveNewProfile(
388386 const configFilePath : string = getDatabricksConfigFilePath ( ) . fsPath ;
389387 let shouldBackup = true ;
390388 try {
391- await loadConfigFile ( configFilePath ) ;
389+ await stat ( configFilePath ) ;
392390 } catch ( e ) {
393391 shouldBackup = false ;
394392 await createFile ( configFilePath ) ;
@@ -450,19 +448,21 @@ export async function listProfiles(cliWrapper: CliWrapper) {
450448 title : "Loading Databricks profiles" ,
451449 } ,
452450 async ( ) => {
453- const profiles = (
454- await cliWrapper . listProfiles (
455- FileUtils . getDatabricksConfigFilePath ( ) . fsPath
456- )
457- ) . filter ( ( profile ) => {
451+ const cfgPath = FileUtils . getDatabricksConfigFilePath ( ) . fsPath ;
452+ try {
453+ await stat ( cfgPath ) ;
454+ } catch ( e ) {
455+ return [ ] ;
456+ }
457+ const allProfiles = await cliWrapper . listProfiles ( cfgPath ) ;
458+ const profiles = allProfiles . filter ( ( profile ) => {
458459 try {
459460 UrlUtils . normalizeHost ( profile . host ! . toString ( ) ) ;
460461 return true ;
461462 } catch ( e ) {
462463 return false ;
463464 }
464465 } ) ;
465-
466466 return profiles ;
467467 }
468468 ) ;
0 commit comments