From: Kevin Sawicki Date: Thu, 4 Feb 2016 01:12:09 +0000 (-0800) Subject: Delete extensions file when there are no loaded extensions X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6252511b7fa5505ba4f47dfad9ff16f26fe0c5e0;p=electron.git Delete extensions file when there are no loaded extensions --- diff --git a/atom/browser/lib/chrome-extension.js b/atom/browser/lib/chrome-extension.js index eaed9b65..e396989b 100644 --- a/atom/browser/lib/chrome-extension.js +++ b/atom/browser/lib/chrome-extension.js @@ -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 }