Skip to content

Commit bb37d83

Browse files
committed
account for .credentials and .config not having been created yet in call to get_credentials/config_file
1 parent c47e999 commit bb37d83

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/Plotly.jl

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ function set_credentials_file(input_creds::Dict)
8484
# Save Plotly endpoint configuration as JSON key-value pairs in
8585
# userhome/.plotly/.credentials. This includes username and api_key.
8686

87-
prev_creds = get_credentials_file()
87+
prev_creds = {}
88+
89+
try
90+
prev_creds = get_credentials_file()
91+
end
8892

8993
# plotly credentials file
9094
userhome = get(ENV, "HOME", "")
@@ -99,7 +103,7 @@ function set_credentials_file(input_creds::Dict)
99103
end
100104

101105
#merge input creds with prev creds
102-
if prev_creds != nothing
106+
if prev_creds != {}
103107
creds = merge(prev_creds, input_creds)
104108
else
105109
creds = input_creds
@@ -115,7 +119,11 @@ function set_config_file(input_config::Dict)
115119
# Save Plotly endpoint configuration as JSON key-value pairs in
116120
# userhome/.plotly/.config. This includes the plotly_domain, and plotly_api_domain.
117121

118-
prev_config = get_config_file()
122+
prev_config = {}
123+
124+
try
125+
prev_config = get_config_file()
126+
end
119127

120128
# plotly configuration file
121129
userhome = get(ENV, "HOME", "")
@@ -130,7 +138,7 @@ function set_config_file(input_config::Dict)
130138
end
131139

132140
#merge input config with prev config
133-
if prev_config != nothing
141+
if prev_config != {}
134142
config = merge(prev_config, input_config)
135143
else
136144
config = input_config
@@ -158,6 +166,11 @@ function get_credentials_file()
158166

159167
creds_file = open(plotly_credentials_file)
160168
creds = JSON.parse(creds_file)
169+
170+
if creds == nothing
171+
creds = {}
172+
end
173+
161174
return creds
162175
end
163176

@@ -177,6 +190,11 @@ function get_config_file()
177190

178191
config_file = open(plotly_config_file)
179192
config = JSON.parse(config_file)
193+
194+
if config == nothing
195+
config = {}
196+
end
197+
180198
return config
181199
end
182200

0 commit comments

Comments
 (0)