Make “style sheet” two words in package.json metadata
Rename `stylesheets` -> `styleSheets` Rename `stylesheetsMain` -> `mainStyleSheet`
Esse commit está contido em:
@@ -138,7 +138,7 @@ taken from the active theme's [ui-variables.less][ui-variables]. For more
|
||||
information, see the [theme variables docs][theme-variables]. If you follow this
|
||||
guideline, your package will look good out of the box with any theme!
|
||||
|
||||
An optional `stylesheets` array in your _package.json_ can list the style sheets
|
||||
An optional `styleSheets` array in your _package.json_ can list the style sheets
|
||||
by name to specify a loading order; otherwise, style sheets are loaded
|
||||
alphabetically.
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
styleSheets: ['2', '1']
|
||||
@@ -1 +1 @@
|
||||
stylesheets: ['2', '1']
|
||||
styleSheets: ['2', '1']
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"theme": "ui",
|
||||
"stylesheets": ["first.css", "second.less", "last.css"]
|
||||
"styleSheets": ["first.css", "second.less", "last.css"]
|
||||
}
|
||||
|
||||
@@ -352,11 +352,11 @@ describe "PackageManager", ->
|
||||
expect(atom.packages.isPackageActive("package-with-empty-menu")).toBe true
|
||||
|
||||
describe "stylesheet loading", ->
|
||||
describe "when the metadata contains a 'stylesheets' manifest", ->
|
||||
it "loads stylesheets from the stylesheets directory as specified by the manifest", ->
|
||||
one = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/styles/1.css")
|
||||
two = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/styles/2.less")
|
||||
three = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/styles/3.css")
|
||||
describe "when the metadata contains a 'styleSheets' manifest", ->
|
||||
it "loads style sheets from the styles directory as specified by the manifest", ->
|
||||
one = require.resolve("./fixtures/packages/package-with-style-sheets-manifest/styles/1.css")
|
||||
two = require.resolve("./fixtures/packages/package-with-style-sheets-manifest/styles/2.less")
|
||||
three = require.resolve("./fixtures/packages/package-with-style-sheets-manifest/styles/3.css")
|
||||
|
||||
one = atom.themes.stringToId(one)
|
||||
two = atom.themes.stringToId(two)
|
||||
@@ -367,7 +367,7 @@ describe "PackageManager", ->
|
||||
expect(atom.themes.stylesheetElementForId(three)).toBeNull()
|
||||
|
||||
waitsForPromise ->
|
||||
atom.packages.activatePackage("package-with-stylesheets-manifest")
|
||||
atom.packages.activatePackage("package-with-style-sheets-manifest")
|
||||
|
||||
runs ->
|
||||
expect(atom.themes.stylesheetElementForId(one)).not.toBeNull()
|
||||
@@ -375,8 +375,8 @@ describe "PackageManager", ->
|
||||
expect(atom.themes.stylesheetElementForId(three)).toBeNull()
|
||||
expect($('#jasmine-content').css('font-size')).toBe '1px'
|
||||
|
||||
describe "when the metadata does not contain a 'stylesheets' manifest", ->
|
||||
it "loads all stylesheets from the stylesheets directory", ->
|
||||
describe "when the metadata does not contain a 'styleSheets' manifest", ->
|
||||
it "loads all style sheets from the styles directory", ->
|
||||
one = require.resolve("./fixtures/packages/package-with-styles/styles/1.css")
|
||||
two = require.resolve("./fixtures/packages/package-with-styles/styles/2.less")
|
||||
three = require.resolve("./fixtures/packages/package-with-styles/styles/3.test-context.css")
|
||||
@@ -537,9 +537,9 @@ describe "PackageManager", ->
|
||||
|
||||
runs ->
|
||||
atom.packages.deactivatePackage('package-with-styles')
|
||||
one = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/styles/1.css")
|
||||
two = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/styles/2.less")
|
||||
three = require.resolve("./fixtures/packages/package-with-stylesheets-manifest/styles/3.css")
|
||||
one = require.resolve("./fixtures/packages/package-with-style-sheets-manifest/styles/1.css")
|
||||
two = require.resolve("./fixtures/packages/package-with-style-sheets-manifest/styles/2.less")
|
||||
three = require.resolve("./fixtures/packages/package-with-style-sheets-manifest/styles/3.css")
|
||||
expect(atom.themes.stylesheetElementForId(one)).not.toExist()
|
||||
expect(atom.themes.stylesheetElementForId(two)).not.toExist()
|
||||
expect(atom.themes.stylesheetElementForId(three)).not.toExist()
|
||||
|
||||
+13
-5
@@ -42,6 +42,15 @@ class Package
|
||||
throw error unless ignoreErrors
|
||||
metadata ?= {}
|
||||
metadata.name = packageName
|
||||
|
||||
if metadata.stylesheetMain?
|
||||
deprecate("Use the `mainStyleSheet` key instead of `stylesheetMain` in your `package.json`", {packageName})
|
||||
metadata.mainStyleSheet = metadata.stylesheetMain
|
||||
|
||||
if metadata.stylesheets?
|
||||
deprecate("Use the `styleSheets` key instead of `stylesheets` in your `package.json`", {packageName})
|
||||
metadata.styleSheets = metadata.stylesheets
|
||||
|
||||
metadata
|
||||
|
||||
keymaps: null
|
||||
@@ -239,11 +248,10 @@ class Package
|
||||
|
||||
getStylesheetPaths: ->
|
||||
stylesheetDirPath = @getStylesheetsPath()
|
||||
|
||||
if @metadata.stylesheetMain
|
||||
[fs.resolve(@path, @metadata.stylesheetMain)]
|
||||
else if @metadata.stylesheets
|
||||
@metadata.stylesheets.map (name) -> fs.resolve(stylesheetDirPath, name, ['css', 'less', ''])
|
||||
if @metadata.mainStyleSheet
|
||||
[fs.resolve(@path, @metadata.mainStyleSheet)]
|
||||
else if @metadata.styleSheets
|
||||
@metadata.styleSheets.map (name) -> fs.resolve(stylesheetDirPath, name, ['css', 'less', ''])
|
||||
else if indexStylesheet = fs.resolve(@path, 'index', ['css', 'less'])
|
||||
[indexStylesheet]
|
||||
else
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário