From c6fc49c7833ea2bf8bfda06834da2c550e53ac5e Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Sat, 22 May 2010 14:49:34 +0200 Subject: [PATCH] Add package.json to CommonJS package (`rake commonjs`). Use fancy regex to auto-fill the version number. Closes #37. --- Rakefile | 16 ++++++++++++++-- mustache-commonjs/package.json | 7 +++++++ package.json | 7 ------- 3 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 mustache-commonjs/package.json delete mode 100644 package.json diff --git a/Rakefile b/Rakefile index e27970c92..b32f2b04f 100644 --- a/Rakefile +++ b/Rakefile @@ -28,15 +28,27 @@ def templated_build(name, opts={}) sh "mkdir -p #{opts[:location]}" if opts[:location] sh "cat #{source}/#{target_js}.tpl.pre mustache.js \ #{source}/#{target_js}.tpl.post > #{opts[:location] || '.'}/#{target_js}" - puts "Done, see #{opts[:location] || '.'}/#{target_js}" + + # extra + if opts[:extra] + sh "cat #{source}/#{opts[:extra]} | sed -e 's/{{version}}/#{version}/' > #{opts[:location]}/#{opts[:extra]}" + end + + puts "Done, see #{opts[:location] || '.'}/#{target_js}" + end end -templated_build "CommonJS", :location => "lib" +templated_build "CommonJS", :location => "lib", :extra => "package.json" templated_build "jQuery" templated_build "Dojo", :location => "dojox/string" templated_build "YUI3", :location => "yui3/mustache" +def version + File.read("mustache.js").match('version: "([^\"]+)",$')[1] +end + + desc "Remove temporary files." task :clean do sh "git clean -fdx" diff --git a/mustache-commonjs/package.json b/mustache-commonjs/package.json new file mode 100644 index 000000000..74d3abaa5 --- /dev/null +++ b/mustache-commonjs/package.json @@ -0,0 +1,7 @@ +{ + "name": "mustache", + "author": "http://mustache.github.com/", + "description": "{{ mustache }} in JavaScript — Logic-less templates.", + "keywords": ["template"], + "version": "{{version}}" +} diff --git a/package.json b/package.json deleted file mode 100644 index 54a86f983..000000000 --- a/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "mustache", - "author": "Jan Lehnardt", - "description": "{{mustaches}} in JavaScript — shameless port from @defunkt", - "keywords": ["template"], - "version": "0.2.3" -}