]> khamidou — GitHub mirrors - electron.git/commitdiff
Call app.getDataPath after app is ready
authorCheng Zhao <zcbenz@gmail.com>
Mon, 19 Jan 2015 01:24:02 +0000 (17:24 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 19 Jan 2015 05:43:18 +0000 (21:43 -0800)
It is possible for users to override the data path.

atom/browser/lib/chrome-extension.coffee

index e62ad5250de472ebe9d9826c151cc724d586f4c5..1b987187c46af6f15eefc4928373a7c043fa71d0 100644 (file)
@@ -34,15 +34,9 @@ getExtensionInfoFromPath = (srcDirectory) ->
       srcDirectory: srcDirectory
     extensionInfoMap[manifest.name]
 
-# Load persistented extensions.
-loadedExtensionsPath = path.join app.getDataPath(), 'DevTools Extensions'
-
-try
-  loadedExtensions = JSON.parse fs.readFileSync(loadedExtensionsPath)
-  loadedExtensions = [] unless Array.isArray loadedExtensions
-  # Preheat the extensionInfo cache.
-  getExtensionInfoFromPath srcDirectory for srcDirectory in loadedExtensions
-catch e
+# The loaded extensions cache and its persistent path.
+loadedExtensions = null
+loadedExtensionsPath = null
 
 # Persistent loaded extensions.
 app.on 'will-quit', ->
@@ -59,6 +53,16 @@ app.once 'ready', ->
   protocol = require 'protocol'
   BrowserWindow = require 'browser-window'
 
+  # Load persistented extensions.
+  loadedExtensionsPath = path.join app.getDataPath(), 'DevTools Extensions'
+
+  try
+    loadedExtensions = JSON.parse fs.readFileSync(loadedExtensionsPath)
+    loadedExtensions = [] unless Array.isArray loadedExtensions
+    # Preheat the extensionInfo cache.
+    getExtensionInfoFromPath srcDirectory for srcDirectory in loadedExtensions
+  catch e
+
   # The chrome-extension: can map a extension URL request to real file path.
   protocol.registerProtocol 'chrome-extension', (request) ->
     parsed = url.parse request.url