forked from mauricecruz/chrome-devtools-zerodarkmatrix-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
75 lines (60 loc) · 1.78 KB
/
Rakefile
File metadata and controls
75 lines (60 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- mode: ruby -*-
# vi: set ft=ruby ts=2 sw=2 sts=2 et :
require 'date'
require 'find'
def ask message
print message
STDIN.gets.chomp
end
module OS
def OS.win?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end
def OS.mac?
(/darwin/ =~ RUBY_PLATFORM) != nil
end
def OS.unix?
!OS.win?
end
def OS.linux?
OS.unix? and !OS.mac?
end
end
desc "Installs the Chrome Developer Tools custom theme file"
task :install, :backup do |t, args|
args.with_defaults(:backup => nil)
home_dir = File.expand_path('~')
chrome_dirs = []
stable_filename = "Custom-Stable.css"
backup_filename = "Custom-old.css"
if OS.mac?
chrome_dirs.push File.join(home_dir, "Library", "Application Support", "Google", "Chrome")
elsif OS.win?
chrome_dirs.push File.join(home_dir, "AppData", "Local", "Google", "Chrome", "User Data")
else
puts "Unsuported OS..."
end
chrome_dirs.each { |chrome_dir|
if File.exist?(chrome_dir)
Dir.glob(File.join(chrome_dir, "*", "")).each { |profile_dir|
profile_name = File.basename(profile_dir)
if profile_name =~ /(Default|Profile [0-9]+)/
theme = stable_filename
version = "Chrome Stable"
puts ""
puts "Found [#{version}] #{profile_name}","-----------------------------"
css_new = File.join(File.dirname(__FILE__), theme)
css_old = File.join(profile_dir, "User StyleSheets", "Custom.css")
if File.exist?(css_old)
css_backup = File.join(profile_dir, "User StyleSheets", backup_filename)
puts "Creating backup..."
FileUtils.cp css_old, css_backup
end
puts "Copying theme..."
FileUtils.cp css_new, css_old
end
}
end
}
end
task :default => [:install]