Delete extensions file when there are no loaded extensions

This commit is contained in:
Kevin Sawicki 2016-02-03 17:12:09 -08:00
parent 5714ae0b73
commit 6252511b7f

View file

@ -54,12 +54,16 @@ app.on('will-quit', function() {
loadedExtensions = Object.keys(extensionInfoMap).map(function(key) {
return extensionInfoMap[key].srcDirectory;
});
try {
fs.mkdirSync(path.dirname(loadedExtensionsPath));
} catch (error) {
// Ignore error
if (loadedExtensions.length > 0) {
try {
fs.mkdirSync(path.dirname(loadedExtensionsPath));
} catch (error) {
// Ignore error
}
return fs.writeFileSync(loadedExtensionsPath, JSON.stringify(loadedExtensions));
} else {
fs.unlinkSync(loadedExtensionsPath);
}
return fs.writeFileSync(loadedExtensionsPath, JSON.stringify(loadedExtensions));
} catch (error) {
// Ignore error
}