forked from cjohansen/sinon-qunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·33 lines (27 loc) · 846 Bytes
/
build
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
#!/usr/bin/env ruby
require "fileutils"
require "pathname"
def add_license(file, version)
contents = File.read(file)
File.open(file, "w") do |f|
f.puts <<PREAMBLE
/**
* sinon-qunit #{version}, #{Time.now.strftime("%Y/%m/%d")}
*
* @author Christian Johansen ([email protected])
*
* #{File.read("LICENSE").split("\n").join("\n * ")}
*/
PREAMBLE
f.puts(contents)
end
end
Dir.chdir(File.dirname(__FILE__)) do
version = File.read("package.json").match(/"version":\s+"(.*)"/)[1]
version_string = ARGV[0] == "plain" ? "" : "-#{version}"
output = "pkg/sinon-qunit#{version_string}.js"
FileUtils.mkdir("pkg") unless File.exists?("pkg")
FileUtils.cp("lib/sinon-qunit.js", "pkg/sinon-qunit#{version_string}.js")
add_license("pkg/sinon-qunit#{version_string}.js", version)
puts "Built sinon-qunit #{version}"
end