Comparing version 0.0.3 to 0.0.4
22
index.js
@@ -11,9 +11,24 @@ | ||
function callmin(file, min_file) { | ||
function callmin(file, min_file, next) { | ||
if (typeof file == 'string') file = [file] | ||
var newestSource = 0 | ||
file.forEach(function(name, i, arr){ | ||
if (!fs.existsSync(name)) { | ||
name = arr[i] = require.resolve(name) | ||
} | ||
var stat = fs.statSync(name) | ||
if (newestSource < stat.mtime) newestSource = stat.mtime | ||
}) | ||
if (newestSource < fs.statSync(min_file).mtime) return next && next(); | ||
console.log("# Build "+min_file) | ||
var http = require('http') | ||
, querystring = require('querystring') | ||
, fileString = file.map(function(name){ | ||
return fs.readFileSync( fs.existsSync(name) ? name : require.resolve(name), 'utf8') | ||
return fs.readFileSync(name, 'utf8') | ||
}).join('\n') | ||
@@ -59,2 +74,3 @@ | ||
} | ||
next && next() | ||
}) | ||
@@ -69,2 +85,4 @@ }); | ||
exports.callmin = callmin | ||
function buildAll() { | ||
@@ -71,0 +89,0 @@ var min = Object.keys(conf.buildman || {}) |
{ | ||
"name": "buildman", | ||
"version": "0.0.3", | ||
"description": "Expiremental webapp bundler", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node tests/run.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/lauriro/buildman.git" | ||
}, | ||
"keywords": [ | ||
"readme" | ||
], | ||
"author": "Lauri Rooden <lauri@rooden.ee>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/lauriro/buildman/issues" | ||
} | ||
"name": "buildman", | ||
"version": "0.0.4", | ||
"description": "Expiremental webapp bundler", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node tests/run.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/lauriro/buildman.git" | ||
}, | ||
"keywords": [ | ||
"readme" | ||
], | ||
"author": "Lauri Rooden <lauri@rooden.ee>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"testman": "*" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/lauriro/buildman/issues" | ||
} | ||
} |
var buildman = require("../") | ||
, fs = require('fs') | ||
, testfile = "tests/test-min.js" | ||
require("testman"). | ||
describe("buildman"). | ||
it( "should minimize js" ). | ||
run(function(){ | ||
console.log("# run 1") | ||
buildman.callmin(["dummy"], testfile, this.wait() ) | ||
}). | ||
run(function(){ | ||
console.log("# run 2") | ||
}). | ||
equal( | ||
function(){ | ||
console.log("# run 3") | ||
return ""+fs.readFileSync(testfile) | ||
}, | ||
function(){ | ||
return ""+fs.readFileSync("tests/target-min.js") | ||
} | ||
). | ||
run(function(){ | ||
console.log("# run 4") | ||
}). | ||
done() |
3554
7
103
1
6