@@ -387,7 +387,7 @@ export class Config extends ConfigFile<ConfigFile.Options, ConfigProperties> {
387
387
388
388
await config . read ( ) ;
389
389
390
- if ( value == null || value === undefined ) {
390
+ if ( value == null ) {
391
391
config . unset ( propertyName ) ;
392
392
} else {
393
393
config . set ( propertyName , value ) ;
@@ -598,8 +598,8 @@ export class Config extends ConfigFile<ConfigFile.Options, ConfigProperties> {
598
598
}
599
599
600
600
/**
601
- * If toOld is specified: migrate all deprecated configs back to their original key.
602
- * - For example, target-org will be renamed to defaultusername.
601
+ * convert from "new" to "old" config names
602
+ * - For example, ` target-org` will be renamed to ` defaultusername` .
603
603
*/
604
604
const translateToSfdx = ( sfContents : ConfigProperties ) : ConfigProperties =>
605
605
Object . fromEntries (
@@ -610,8 +610,8 @@ const translateToSfdx = (sfContents: ConfigProperties): ConfigProperties =>
610
610
) ;
611
611
612
612
/**
613
- * If toOld is specified: migrate all deprecated configs to the new key.
614
- * - For example, target-org will be renamed to defaultusername.
613
+ * convert from "old" to " new" config names
614
+ * - For example, `defaultusername` will be renamed to `target-org`
615
615
*/
616
616
const translateToSf = ( sfdxContents : ConfigProperties , SfConfig : Config ) : ConfigProperties =>
617
617
Object . fromEntries (
@@ -642,20 +642,23 @@ const writeToSfdx = async (path: string, contents: ConfigProperties): Promise<vo
642
642
const translated = translateToSfdx ( contents ) ;
643
643
await fs . promises . mkdir ( pathDirname ( path ) , { recursive : true } ) ;
644
644
await fs . promises . writeFile ( path , JSON . stringify ( translated , null , 2 ) ) ;
645
- } catch ( error ) {
646
- /* Do nothing */
645
+ } catch ( e ) {
646
+ const logger = Logger . childFromRoot ( 'core:config:writeToSfdx' ) ;
647
+ logger . debug ( `Error writing to sfdx config file at ${ path } : ${ e instanceof Error ? e . message : '' } ` ) ;
647
648
}
648
649
} ;
649
650
650
651
/** turn the sfdx config file into a LWWState based on its contents and its timestamp */
651
- const stateFromSfdxFileSync = ( filePath : string , config : Config ) : LWWState < ConfigProperties > => {
652
+ const stateFromSfdxFileSync = ( path : string , config : Config ) : LWWState < ConfigProperties > => {
652
653
try {
653
- const fileContents = fs . readFileSync ( filePath , 'utf8' ) ;
654
- const mtimeNs = fs . statSync ( filePath , { bigint : true } ) . mtimeNs ;
655
- const translatedContents = translateToSf ( parseJsonMap < ConfigProperties > ( fileContents , filePath ) , config ) ;
654
+ const fileContents = fs . readFileSync ( path , 'utf8' ) ;
655
+ const mtimeNs = fs . statSync ( path , { bigint : true } ) . mtimeNs ;
656
+ const translatedContents = translateToSf ( parseJsonMap < ConfigProperties > ( fileContents , path ) , config ) ;
656
657
// get the file timestamp
657
658
return stateFromContents ( translatedContents , mtimeNs ) ;
658
659
} catch ( e ) {
660
+ const logger = Logger . childFromRoot ( 'core:config:stateFromSfdxFileSync' ) ;
661
+ logger . debug ( `Error reading state from sfdx config file at ${ path } : ${ e instanceof Error ? e . message : '' } ` ) ;
659
662
return { } ;
660
663
}
661
664
} ;
0 commit comments