Files
atom/src/app/package.coffee
Nathan Sobo a9bb4ea163 When loading a package, honor the 'keymaps' manifest in package.json
Also, add a spec to cover the loading of keymaps in `atom-spec` and
reset the `keymap`'s internal data after each spec gets run to prevent
test pollution with keymaps.
2013-01-03 15:17:09 -07:00

36 lines
821 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()
name: null
path: null
requireModule: null
module: null
constructor: (@name) ->
@path = require.resolve(@name, verifyExistence: false)
throw new Error("No package found named '#{@name}'") unless @path
if fs.isDirectory(@path)
@requireModule = false
else
@requireModule = true
@path = fs.directory(@path)
load: ->
for grammar in @getGrammars()
syntax.addGrammar(grammar)
for { selector, properties } in @getScopedProperties()
syntax.addProperties(selector, properties)