Copy themes to ~/.atom/themes when config loads

This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-02-22 14:44:57 -08:00
parent fa81871907
commit 31d8151c3e
3 changed files with 19 additions and 25 deletions

View File

@@ -1,5 +1,4 @@
ATOM_SRC_PATH = File.dirname(__FILE__)
DOT_ATOM_PATH = ENV['HOME'] + "/.atom"
BUILD_DIR = 'atom-build'
require 'erb'
@@ -53,31 +52,11 @@ task :install => [:clean, :build] do
f.chmod(0755)
end
Rake::Task["create-dot-atom"].invoke()
Rake::Task["clone-default-bundles"].invoke()
puts "\033[32mType `atom` to start Atom! In Atom press `cmd-,` to edit your `~/.atom` directory\033[0m"
end
desc "Creates .atom file if non exists"
task "create-dot-atom" do
dot_atom_template_path = ATOM_SRC_PATH + "/dot-atom"
if File.exists?(DOT_ATOM_PATH)
user_config = "#{DOT_ATOM_PATH}/user.coffee"
old_user_config = "#{DOT_ATOM_PATH}/atom.coffee"
if File.exists?(old_user_config)
`mv #{old_user_config} #{user_config}`
puts "\033[32mRenamed #{old_user_config} to #{user_config}\033[0m"
end
else
`mkdir "#{DOT_ATOM_PATH}"`
`cp -r "#{dot_atom_template_path}/" "#{DOT_ATOM_PATH}"/`
`cp -r "#{ATOM_SRC_PATH}/themes/" "#{DOT_ATOM_PATH}"/themes/`
end
end
desc "Clone default bundles into vendor/bundles directory"
task "clone-default-bundles" do
`git submodule --quiet sync`

View File

@@ -113,16 +113,23 @@ describe "Config", ->
describe "initializeConfigDirectory()", ->
beforeEach ->
config.configDirPath = '/tmp/dot-atom-dir'
expect(fs.exists(config.configDirPath)).toBeFalsy()
afterEach ->
fs.remove('/tmp/dot-atom-dir') if fs.exists('/tmp/dot-atom-dir')
describe "when the configDirPath doesn't exist", ->
it "copies the contents of dot-atom to ~/.atom if it doesn't exist", ->
expect(fs.exists(config.configDirPath)).toBeFalsy()
it "copies the contents of dot-atom to ~/.atom", ->
config.initializeConfigDirectory()
expect(fs.exists(config.configDirPath)).toBeTruthy()
expect(fs.exists(fs.join(config.configDirPath, 'packages'))).toBeTruthy()
expect(fs.exists(fs.join(config.configDirPath, 'snippets'))).toBeTruthy()
expect(fs.exists(fs.join(config.configDirPath, 'themes'))).toBeTruthy()
expect(fs.isFile(fs.join(config.configDirPath, 'config.cson'))).toBeTruthy()
it "copies the bundles themes to ~/.atom", ->
config.initializeConfigDirectory()
expect(fs.isFile(fs.join(config.configDirPath, 'themes/atom-dark-ui/package.cson'))).toBeTruthy()
expect(fs.isFile(fs.join(config.configDirPath, 'themes/atom-light-ui/package.cson'))).toBeTruthy()
expect(fs.isFile(fs.join(config.configDirPath, 'themes/atom-dark-syntax.css'))).toBeTruthy()
expect(fs.isFile(fs.join(config.configDirPath, 'themes/atom-light-syntax.css'))).toBeTruthy()

View File

@@ -34,13 +34,21 @@ class Config
return if fs.exists(@configDirPath)
fs.makeDirectory(@configDirPath)
templateConfigDirPath = fs.resolve(window.resourcePath, 'dot-atom')
onConfigDirFile = (path) =>
templatePath = fs.join(templateConfigDirPath, path)
configPath = fs.join(@configDirPath, path)
fs.write(configPath, fs.read(templatePath))
onConfigDirPath = (path) -> true
fs.traverseTree(templateConfigDirPath, onConfigDirFile, onConfigDirPath)
fs.traverseTree(templateConfigDirPath, onConfigDirFile, (path) -> true)
configThemeDirPath = fs.join(@configDirPath, 'themes')
onThemeDirFile = (path) ->
templatePath = fs.join(bundledThemesDirPath, path)
configPath = fs.join(configThemeDirPath, path)
fs.write(configPath, fs.read(templatePath))
fs.traverseTree(bundledThemesDirPath, onThemeDirFile, (path) -> true)
load: ->
@initializeConfigDirectory()