mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Allow packages to have stylesheet manifests
This commit is contained in:
committed by
Nathan Sobo
parent
c8804359c9
commit
8c1f5658be
@@ -35,7 +35,7 @@ describe "the `atom` global", ->
|
||||
expect(console.error).not.toHaveBeenCalled()
|
||||
expect(console.warn).not.toHaveBeenCalled()
|
||||
|
||||
it "passes the package its previously serialized state if it exists", ->
|
||||
it "passes the activate method the package's previously serialized state if it exists", ->
|
||||
pack = atom.activatePackage("package-with-serialization")
|
||||
expect(pack.mainModule.someNumber).not.toBe 77
|
||||
pack.mainModule.someNumber = 77
|
||||
@@ -44,7 +44,7 @@ describe "the `atom` global", ->
|
||||
atom.activatePackage("package-with-serialization")
|
||||
expect(pack.mainModule.activate).toHaveBeenCalledWith({someNumber: 77})
|
||||
|
||||
it "logs warning instead of throwing an exception if a package fails to load", ->
|
||||
it "logs warning instead of throwing an exception if the package fails to load", ->
|
||||
config.set("core.disabledPackages", [])
|
||||
spyOn(console, "warn")
|
||||
expect(-> atom.activatePackage("package-that-throws-an-exception")).not.toThrow()
|
||||
@@ -82,7 +82,20 @@ describe "the `atom` global", ->
|
||||
|
||||
describe "stylesheet loading", ->
|
||||
describe "when the metadata contains a 'stylesheets' manifest", ->
|
||||
# WIP
|
||||
it "loads stylesheets from the stylesheets directory as specified by the manifest", ->
|
||||
one = fs.resolveOnLoadPath("package-with-stylesheets-manifest/stylesheets/1.css")
|
||||
two = fs.resolveOnLoadPath("package-with-stylesheets-manifest/stylesheets/2.less")
|
||||
three = fs.resolveOnLoadPath("package-with-stylesheets-manifest/stylesheets/3.css")
|
||||
expect(stylesheetElementForId(one)).not.toExist()
|
||||
expect(stylesheetElementForId(two)).not.toExist()
|
||||
expect(stylesheetElementForId(three)).not.toExist()
|
||||
|
||||
atom.activatePackage("package-with-stylesheets-manifest")
|
||||
|
||||
expect(stylesheetElementForId(one)).toExist()
|
||||
expect(stylesheetElementForId(two)).toExist()
|
||||
expect(stylesheetElementForId(three)).not.toExist()
|
||||
expect($('#jasmine-content').css('font-size')).toBe '1px'
|
||||
|
||||
describe "when the metadata does not contains a 'stylesheets' manifest", ->
|
||||
it "loads all stylesheets from the stylesheets directory", ->
|
||||
|
||||
1
spec/fixtures/packages/package-with-stylesheets-manifest/package.cson
vendored
Normal file
1
spec/fixtures/packages/package-with-stylesheets-manifest/package.cson
vendored
Normal file
@@ -0,0 +1 @@
|
||||
stylesheets: ['2', '1']
|
||||
3
spec/fixtures/packages/package-with-stylesheets-manifest/stylesheets/1.css
vendored
Normal file
3
spec/fixtures/packages/package-with-stylesheets-manifest/stylesheets/1.css
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#jasmine-content {
|
||||
font-size: 1px;
|
||||
}
|
||||
5
spec/fixtures/packages/package-with-stylesheets-manifest/stylesheets/2.less
vendored
Normal file
5
spec/fixtures/packages/package-with-stylesheets-manifest/stylesheets/2.less
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
@size: 2px;
|
||||
|
||||
#jasmine-content {
|
||||
font-size: @size;
|
||||
}
|
||||
3
spec/fixtures/packages/package-with-stylesheets-manifest/stylesheets/3.css
vendored
Normal file
3
spec/fixtures/packages/package-with-stylesheets-manifest/stylesheets/3.css
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
#jasmine-content {
|
||||
font-size: 3px;
|
||||
}
|
||||
@@ -69,9 +69,14 @@ class AtomPackage extends Package
|
||||
|
||||
loadStylesheets: ->
|
||||
@stylesheets = []
|
||||
@stylesheets.push([path, loadStylesheet(path)]) for path in @getStylesheetPaths()
|
||||
|
||||
getStylesheetPaths: ->
|
||||
stylesheetDirPath = fsUtils.join(@path, 'stylesheets')
|
||||
for stylesheetPath in fsUtils.list(stylesheetDirPath, ['css', 'less']) ? []
|
||||
@stylesheets.push([stylesheetPath, loadStylesheet(stylesheetPath)])
|
||||
if @metadata.stylesheets
|
||||
@metadata.stylesheets.map (name) -> fsUtils.resolve(stylesheetDirPath, name, ['css', 'less', ''])
|
||||
else
|
||||
fsUtils.list(stylesheetDirPath, ['css', 'less']) ? []
|
||||
|
||||
loadGrammars: ->
|
||||
@grammars = []
|
||||
|
||||
Reference in New Issue
Block a user