Skip to content

Commit

Permalink
adding more sensible common lib
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffsu committed Mar 1, 2011
1 parent 77ff30d commit a91e0e4
Show file tree
Hide file tree
Showing 25 changed files with 1,461 additions and 623 deletions.
16 changes: 13 additions & 3 deletions Rakefile
Expand Up @@ -47,13 +47,23 @@ task :test => [ 'test:test' ]
desc "ERBify all distributions"
task :dist do
def js(f)
return File.read("./src/#{f}")
if (f.match(/\.js2$/))
return `js2-node render ./src/#{f}`
else
return File.read("./src/#{f}")
end
end

core = %W{ js2-class.js js2-lexer.js js2-parser.js }.collect do |f|
js(f)
core = %W{ js2-boot.js js2-class.js js2-lexer.js js2-parser.js }.collect do |f|
js("core/#{f}")
end.join("\n");

common = %W{ Array FileSystem Updater Commander NodeFileAdapter }.collect do |f|
js("common/#{f}.js2")
end.join("\n");

core += common

Dir["./dist-templates/*.erb"].each do |file|
puts "processing: #{file}"
template = ERB.new(File.read(file))
Expand Down
10 changes: 2 additions & 8 deletions dist-templates/js2-node.js.erb
@@ -1,12 +1,6 @@
JS2 = (function () {
<%= js 'js2-helper.js' %>
JS2.MODE = 'node';
JS2.ROOT = global;
JS2 = (function (root) {
<%= core %>
<%= js 'js2-fs.js' %>
<%= js 'js2-command.js' %>

return JS2;
})();
})(GLOBAL);

exports.JS2 = JS2;
5 changes: 1 addition & 4 deletions dist-templates/js2-parser.js.erb
@@ -1,8 +1,5 @@
var JS2 = (function (root) {
<%= js 'js2-helper.js' %>
JS2.MODE = 'web_parser';
JS2.ROOT = root;
<%= core %>
<%= js 'js2-ajax.js' %>
<%= js 'core/js2-ajax.js' %>
return JS2;
})(window);
6 changes: 0 additions & 6 deletions dist-templates/js2-ruby.js.erb
@@ -1,10 +1,4 @@
var JS2 = (function (root) {
<%= js 'js2-helper.js' %>
JS2.MODE = 'ruby';
JS2.ROOT = root;

<%= core %>
<%= js 'js2-command.js' %>

return JS2;
})(this);
7 changes: 3 additions & 4 deletions dist-templates/js2-web.js.erb
@@ -1,7 +1,6 @@
var JS2 = (function (root) {
<%= js 'js2-helper.js' %>
JS2.MODE = 'web';
JS2.ROOt = root;
<%= js 'js2-class.js' %>
<%= js 'core/js2-boot.js' %>
<%= js 'core/js2-class.js' %>
<%= js 'common/Array.js2' %>
return JS2;
})(window);

0 comments on commit a91e0e4

Please sign in to comment.