-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
56 lines (46 loc) · 1.21 KB
/
Rakefile
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
# frozen_string_literal: true
require "json"
desc "Build packages"
task :build do
components = [
"_locales",
"content",
"images",
"libraries",
"svg",
"LICENSE",
"options.html",
"options.js",
"README.md",
"manifest.json"
]
base = File.dirname(__FILE__)
manifests = File.join(base, "manifests", "*")
Dir.glob(manifests).each do |m|
version = JSON.parse(File.read(m))["version"]
updated = ""
File.open("options.html", "r") do |f|
updated = f.read.sub(%r{<span class='version'>.*?</span>}) { "<span class='version'>#{version}</span>" }
end
File.open("options.html", "w") do |f|
f.write(updated)
end
case m
when /\.v3\.json\z/
`ln #{m} manifest.json`
`zip -r fastmail-plus-chrome.zip #{components.join(" ")}`
when /\.v2\.json\z/
`ln #{m} manifest.json`
`zip -r fastmail-plus-firefox.zip #{components.join(" ")}`
end
`rm manifest.json`
end
end
desc "switches to Firefox as main manifest"
task :firefox do
`ln --force --symbolic manifests/manifest.v2.json manifest.json`
end
desc "switches to Chrome as main manifest"
task :chrome do
`ln --force --symbolic manifests/manifest.v3.json manifest.json`
end