Assign package stylesheet context based on double-extension in file name

If stylesheet files are named with 2 extensions, the first extension is
used as the context argument when the package’s stylesheets are loaded.
This allows people to target the text editor by naming their stylesheet
`index.atom-text-editor.less`.
This commit is contained in:
Nathan Sobo
2014-10-21 15:24:35 -06:00
parent 84d1101903
commit d060ecdc24
3 changed files with 12 additions and 1 deletions

View File

@@ -176,10 +176,15 @@ class Package
activateStylesheets: ->
return if @stylesheetsActivated
context = 'atom-text-editor' if @metadata.theme is 'syntax'
group = @getStylesheetType()
@stylesheetDisposables = new CompositeDisposable
for [sourcePath, source] in @stylesheets
if match = path.basename(sourcePath).match(/[^.]*\.([^.]*)\./)
context = match[1]
else if @metadata.theme is 'syntax'
context = 'atom-text-editor'
@stylesheetDisposables.add(atom.styles.addStyleSheet(source, {sourcePath, group, context}))
@stylesheetsActivated = true