Browse files

Fix the cake dist task

  • Loading branch information...
1 parent 233722c commit a6390dec413f6a2ce2195a463fc5b15ed4ba99d1 @sstephenson committed Mar 10, 2011
Showing with 55 additions and 48 deletions.
  1. +2 −2 .gitignore
  2. +53 −46 Cakefile
View
4 .gitignore
@@ -1,2 +1,2 @@
-dist/
-node_modules/
+/dist
+/node_modules
View
99 Cakefile
@@ -1,10 +1,16 @@
{exec} = require 'child_process'
-build = (callback) ->
- exec 'coffee -co lib src', (err, stdout, stderr) ->
+run = (command, callback) ->
+ exec command, (err, stdout, stderr) ->
console.warn stderr if stderr
callback?() unless err
+build = (callback) ->
+ run 'coffee -co lib src', callback
+
+bundle = (callback) ->
+ run 'npm --loglevel silent bundle', callback
+
task "build", "Build lib/eco/ from src/eco/", ->
build()
@@ -55,51 +61,52 @@ task "dist", "Generate dist/eco.js", ->
version = JSON.parse(read "package.json").version
- modules =
- "eco": read "lib/eco.js"
- "eco/compiler": coffee read "lib/eco/compiler.coffee"
- "eco/preprocessor": coffee read "lib/eco/preprocessor.coffee"
- "eco/scanner": coffee read "lib/eco/scanner.coffee"
- "eco/util": coffee read "lib/eco/util.coffee"
- "strscan": read "vendor/strscan/lib/strscan.js"
- "coffee-script": stub "CoffeeScript"
-
- package = for name, source of modules
- """
- '#{name}': function(module, require, exports) {
- #{source}
- }
+ build -> bundle ->
+ modules =
+ "eco": read "lib/eco/index.js"
+ "./compiler": read "lib/eco/compiler.js"
+ "./preprocessor": read "lib/eco/preprocessor.js"
+ "./scanner": read "lib/eco/scanner.js"
+ "./util": read "lib/eco/util.js"
+ "strscan": read "node_modules/strscan/lib/strscan.js"
+ "coffee-script": stub "CoffeeScript"
+
+ package = for name, source of modules
+ """
+ '#{name}': function(module, require, exports) {
+ #{source}
+ }
+ """
+
+ header = """
+ /**
+ * Eco Compiler v#{version}
+ * http://github.com/sstephenson/eco
+ *
+ * Copyright (c) 2011 Sam Stephenson
+ * Released under the MIT License
+ */
"""
- header = """
- /**
- * Eco Compiler v#{version}
- * http://github.com/sstephenson/eco
- *
- * Copyright (c) 2010 Sam Stephenson
- * Released under the MIT License
- */
- """
-
- source = """
- this.eco = (function(modules) {
- return function require(name) {
- var fn, module = {id: name, exports: {}};
- if (fn = modules[name]) {
- fn(module, require, module.exports);
- return module.exports;
- } else {
- throw 'Cannot find module \\'' + name + '\\'';
- }
- };
- })({
- #{package.join ',\n'}
- })('eco');
- """
+ source = """
+ this.eco = (function(modules) {
+ return function require(name) {
+ var fn, module = {id: name, exports: {}};
+ if (fn = modules[name]) {
+ fn(module, require, module.exports);
+ return module.exports;
+ } else {
+ throw 'Cannot find module \\'' + name + '\\'';
+ }
+ };
+ })({
+ #{package.join ',\n'}
+ })('eco');
+ """
- try
- fs.mkdirSync "#{__dirname}/dist", 0755
- catch err
+ try
+ fs.mkdirSync "#{__dirname}/dist", 0755
+ catch err
- minify source, {}, (output) ->
- fs.writeFileSync "#{__dirname}/dist/eco.js", "#{header}\n#{output}"
+ minify source, {}, (output) ->
+ fs.writeFileSync "#{__dirname}/dist/eco.js", "#{header}\n#{output}"

0 comments on commit a6390de

Please sign in to comment.