-
Notifications
You must be signed in to change notification settings - Fork 196
/
rakefile.rb
50 lines (43 loc) · 1017 Bytes
/
rakefile.rb
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
require "uglifier"
source_files = [
"src/license.txt",
"src/pre.txt",
"src/Core.js",
"src/Page.js",
"src/Send.js",
"src/pages/Form.js",
"src/pages/Review.js",
"src/pages/Screenshot.js",
"src/send/xhr.js",
"src/post.txt",
]
def get_the_file(filename)
# Create or blank the compiled file
if File.exists?(filename)
File.open(filename, 'w') {|file| file.truncate(0) }
else
File.new(filename, "w")
end
File.open(filename, "w")
end
def concatenate(file_array)
concat = ""
file_array.each do |file|
src = File.open(file, "r")
concat << src.read << "\n"
src.close
end
return concat
end
task :compile_unminified do
feedback = get_the_file "feedback.js"
feedback.puts concatenate source_files
end
# Runs fedback.js through Uglifyjs
task :compile_minified do
min_feedback = get_the_file "feedback.min.js"
min_feedback.puts Uglifier.compile(concatenate source_files)
end
task :compile_all => [:compile_unminified, :compile_minified] do
puts "Done!"
end