Skip to content

Commit c6fc49c

Browse files
committed
Add package.json to CommonJS package (rake commonjs).
Use fancy regex to auto-fill the version number. Closes janl#37.
1 parent 3abfafa commit c6fc49c

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

Rakefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,27 @@ def templated_build(name, opts={})
2828
sh "mkdir -p #{opts[:location]}" if opts[:location]
2929
sh "cat #{source}/#{target_js}.tpl.pre mustache.js \
3030
#{source}/#{target_js}.tpl.post > #{opts[:location] || '.'}/#{target_js}"
31-
puts "Done, see #{opts[:location] || '.'}/#{target_js}"
31+
32+
# extra
33+
if opts[:extra]
34+
sh "cat #{source}/#{opts[:extra]} | sed -e 's/{{version}}/#{version}/' > #{opts[:location]}/#{opts[:extra]}"
35+
end
36+
37+
puts "Done, see #{opts[:location] || '.'}/#{target_js}"
38+
3239
end
3340
end
3441

35-
templated_build "CommonJS", :location => "lib"
42+
templated_build "CommonJS", :location => "lib", :extra => "package.json"
3643
templated_build "jQuery"
3744
templated_build "Dojo", :location => "dojox/string"
3845
templated_build "YUI3", :location => "yui3/mustache"
3946

47+
def version
48+
File.read("mustache.js").match('version: "([^\"]+)",$')[1]
49+
end
50+
51+
4052
desc "Remove temporary files."
4153
task :clean do
4254
sh "git clean -fdx"

mustache-commonjs/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "mustache",
3+
"author": "http://mustache.github.com/",
4+
"description": "{{ mustache }} in JavaScript — Logic-less templates.",
5+
"keywords": ["template"],
6+
"version": "{{version}}"
7+
}

package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)