mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
TextMatePackage is only designed to load resources out of a TextMate bundle. It's used only at load time, and from that point out we only refer to our own global `syntax` data structure to access the data that it loads.
25 lines
687 B
CoffeeScript
25 lines
687 B
CoffeeScript
fs = require 'fs'
|
|
|
|
module.exports =
|
|
class Package
|
|
@load: (name) ->
|
|
AtomPackage = require 'atom-package'
|
|
TextMatePackage = require 'text-mate-package'
|
|
|
|
if TextMatePackage.testName(name)
|
|
new TextMatePackage(name).load()
|
|
else
|
|
new AtomPackage(name).load()
|
|
|
|
constructor: (@name) ->
|
|
@path = require.resolve(@name, verifyExistence: false)
|
|
throw new Error("No package found named '#{@name}'") unless @path
|
|
@path = fs.directory(@path) unless fs.isDirectory(@path)
|
|
|
|
load: ->
|
|
for grammar in @getGrammars()
|
|
syntax.addGrammar(grammar)
|
|
|
|
for { selector, properties } in @getScopedProperties()
|
|
syntax.addProperties(selector, properties)
|