mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add ~/.atom/packages to the resource load path.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
app = require 'app'
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
protocol = require 'protocol'
|
||||
|
||||
@@ -8,11 +10,18 @@ protocol = require 'protocol'
|
||||
module.exports =
|
||||
class AtomProtocolHandler
|
||||
constructor: (@resourcePath) ->
|
||||
@loadPaths = [
|
||||
path.join(@resourcePath, 'node_modules')
|
||||
path.join(app.getHomeDir(), '.atom', 'packages')
|
||||
]
|
||||
|
||||
@registerAtomProtocol()
|
||||
|
||||
# Private: Creates the 'atom' custom protocol handler.
|
||||
registerAtomProtocol: ->
|
||||
protocol.registerProtocol 'atom', (request) =>
|
||||
relativePath = path.normalize(request.url.substr(7))
|
||||
filePath = path.join(@resourcePath, 'node_modules', relativePath)
|
||||
for loadPath in @loadPaths
|
||||
filePath = path.join(loadPath, relativePath)
|
||||
break if fs.statSyncNoException(filePath)?
|
||||
return new protocol.RequestFileJob(filePath)
|
||||
|
||||
Reference in New Issue
Block a user