mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Bundle a themes directory so we don't depend on ~/.atom/themes
We'll look first in the user themes directory, then in the built-in themes directory. This allows us to default to 'IR_Black' and not crash if the user doesn't setup their `~/.atom/themes` directory.
This commit is contained in:
@@ -9,6 +9,7 @@ Theme = require 'theme'
|
||||
configDirPath = fs.absolute("~/.atom")
|
||||
configJsonPath = fs.join(configDirPath, "config.json")
|
||||
userInitScriptPath = fs.join(configDirPath, "atom.coffee")
|
||||
bundledThemesDirPath = fs.join(resourcePath, "themes")
|
||||
bundledPackagesDirPath = fs.join(resourcePath, "src/packages")
|
||||
userThemesDirPath = fs.join(configDirPath, "themes")
|
||||
userPackagesDirPath = fs.join(configDirPath, "packages")
|
||||
@@ -18,7 +19,7 @@ require.paths.unshift userPackagesDirPath
|
||||
module.exports =
|
||||
class Config
|
||||
configDirPath: configDirPath
|
||||
themeDirPath: userThemesDirPath
|
||||
themeDirPaths: [userThemesDirPath, bundledThemesDirPath]
|
||||
packageDirPaths: [userPackagesDirPath, bundledPackagesDirPath]
|
||||
settings: null
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ class Theme
|
||||
if fs.exists(name)
|
||||
path = name
|
||||
else
|
||||
regex = new RegExp("#{_.escapeRegExp(name)}(\.[^.]*)?$", "i")
|
||||
path = _.find fs.list(config.themeDirPath), (path) -> regex.test(path)
|
||||
path = fs.resolve(config.themeDirPaths..., name)
|
||||
path ?= fs.resolve(config.themeDirPaths..., name + ".tmTheme")
|
||||
|
||||
if @isTextMateTheme(path)
|
||||
theme = @loadTextMateTheme(path)
|
||||
|
||||
@@ -124,6 +124,13 @@ module.exports =
|
||||
md5ForPath: (path) ->
|
||||
$native.md5ForPath(path)
|
||||
|
||||
resolve: (paths...) ->
|
||||
to = paths.pop()
|
||||
for from in paths
|
||||
path = @join(from, to)
|
||||
return path if @exists(path)
|
||||
undefined
|
||||
|
||||
isCompressedExtension: (ext) ->
|
||||
_.contains([
|
||||
'.gz'
|
||||
|
||||
Reference in New Issue
Block a user