Call app.getDataPath after app is ready

It is possible for users to override the data path.
This commit is contained in:
Cheng Zhao 2015-01-18 17:24:02 -08:00
parent 45c26e0e5a
commit 2d1afbf51b

View 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