@salesforce/core 8.25.0 → 8.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/config/configFile.js
CHANGED
|
@@ -169,6 +169,11 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
169
169
|
return this.getContents();
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
+
else if (err.name === 'JsonParseError') {
|
|
173
|
+
this.logger.debug(`Contents of ${this.getPath()} could not be parsed as JSON. Using empty object instead.`);
|
|
174
|
+
this.setContentsFromObject({});
|
|
175
|
+
return this.getContents();
|
|
176
|
+
}
|
|
172
177
|
// Necessarily set this even when an error happens to avoid infinite re-reading.
|
|
173
178
|
// To attempt another read, pass `force=true`.
|
|
174
179
|
throw err;
|
|
@@ -365,6 +370,9 @@ class ConfigFile extends configStore_1.BaseConfigStore {
|
|
|
365
370
|
if (err instanceof Error && err.message.includes('ENOENT')) {
|
|
366
371
|
this.logger.debug(`No file found at ${this.getPath()}. Write will create it.`);
|
|
367
372
|
}
|
|
373
|
+
else if (err instanceof Error && err.name === 'JsonParseError') {
|
|
374
|
+
this.logger.debug(`Could not parse ${this.getPath()} as JSON. Existing contents will be replaced.`);
|
|
375
|
+
}
|
|
368
376
|
else {
|
|
369
377
|
throw err;
|
|
370
378
|
}
|
package/package.json
CHANGED