Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Update dist task for npm 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sstephenson committed May 23, 2011
1 parent ff8cb94 commit 4035e6e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
39 changes: 19 additions & 20 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ build = (callback) ->
run 'coffee -co lib src', callback

bundle = (callback) ->
run 'npm --loglevel silent bundle', callback
run 'npm install', callback

task "build", "Build lib/eco/ from src/eco/", ->
build()
Expand Down Expand Up @@ -44,24 +44,24 @@ task "doc", "Generate documentation", ->
fs.writeFileSync "#{__dirname}/README.md", render "readme"

task "dist", "Generate dist/eco.js", ->
fs = require("fs")
coffee = require("coffee-script").compile
minify = require("closure-compiler").compile

read = (filename) ->
fs.readFileSync "#{__dirname}/#{filename}", "utf-8"

stub = (identifier) -> """
if (typeof #{identifier} !== 'undefined' && #{identifier} != null) {
module.exports = #{identifier};
} else {
throw 'Cannot require \\'' + module.id + '\\': #{identifier} not found';
}
"""
build -> bundle ->
fs = require("fs")
coffee = require("coffee-script").compile
uglify = require("uglify-js")

read = (filename) ->
fs.readFileSync "#{__dirname}/#{filename}", "utf-8"

stub = (identifier) -> """
if (typeof #{identifier} !== 'undefined' && #{identifier} != null) {
module.exports = #{identifier};
} else {
throw 'Cannot require \\'' + module.id + '\\': #{identifier} not found';
}
"""

version = JSON.parse(read "package.json").version
version = JSON.parse(read "package.json").version

build -> bundle ->
modules =
"eco": read "lib/eco/index.js"
"./compiler": read "lib/eco/compiler.js"
Expand All @@ -88,7 +88,7 @@ task "dist", "Generate dist/eco.js", ->
*/
"""

source = """
source = uglify """
this.eco = (function(modules) {
return function require(name) {
var fn, module = {id: name, exports: {}};
Expand All @@ -108,5 +108,4 @@ task "dist", "Generate dist/eco.js", ->
fs.mkdirSync "#{__dirname}/dist", 0755
catch err

minify source, {}, (output) ->
fs.writeFileSync "#{__dirname}/dist/eco.js", "#{header}\n#{output}"
fs.writeFileSync "#{__dirname}/dist/eco.js", "#{header}\n#{source}"
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
{ "strscan": ">=1.0.1"
, "coffee-script": ">=1.0.1"
}
, "devDependencies":
{ "nodeunit": ">=0.5.0"
, "uglify-js": ">=1.0.0"
}
}

0 comments on commit 4035e6e

Please sign in to comment.