Skip to content

Commit

Permalink
Merge branch 'release-0.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ethul committed Dec 13, 2013
2 parents 61bb715 + b67b6ed commit 3e6caa3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
11 changes: 1 addition & 10 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,8 @@ function readFile(encoding,next,file) {
});
}

// The uglify bin script appends a semicolon to the end of the
// processed JavaScript, out.write(text.replace(/;*$/, ";")); It is
// not clear if the middleware should also do this.
function uglifyFile(file) {
return promise(
uglify.uglify.gen_code(
uglify.uglify.ast_squeeze(
uglify.uglify.ast_mangle(uglify.parser.parse(file))
)
)
);
return promise(uglify.minify(file, {fromString: true}).code);
}

// Completes the reserveration for the file in the caching strategy.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "connect-uglify-js"
, "version": "0.0.1"
, "version": "0.0.2"
, "description": "Middleware for Connect to uglify JavaScript files"
, "keywords": ["javascript","uglify-js","connect","middleware"]
, "author": "eric thul <thul.eric@gmail.com>"
, "contributors": [{"name": "eric thul", "email": "thul.eric@gmail.com"}]
, "dependencies": {"uglify-js": ">= 1.2.5","bassline": ">= 0.0.4"}
, "dependencies": {"uglify-js": ">= 2","bassline": ">= 0.0.4"}
, "devDependencies": {
"jasmine-node": ">= 1.0.13"
, "request": ">= 2.9.100"
Expand Down
15 changes: 8 additions & 7 deletions spec/middleware.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var fs = require("fs")
, path = require("path")
, request = require("request")
, connect = require("connect")
, http = require("http")
, middleware = require("../lib/middleware")
, memory = require("../lib/memory-strategy");

Expand All @@ -16,12 +17,12 @@ describe("when the uglify-js middleware is used by connect", function() {
beforeEach(function() {
var port = 12341;
this.uri = "http://localhost:" + port;
this.server = connect.createServer();
this.server.use(middleware(this.root,{
this.connect = connect();
this.connect.use(middleware(this.root,{
encoding: this.encoding,
strategy: this.strategy
}));
this.server.listen(port);
this.server = http.createServer(this.connect).listen(port);
});

beforeEach(function() {
Expand Down Expand Up @@ -136,7 +137,7 @@ describe("when the uglify-js middleware is used by connect", function() {
});
it("should respond with an empty body", function() {
head(this.uri + this.pathname, function(error,response,body) {
expect(body).toEqual(undefined);
expect(body).toEqual('');
});
});
});
Expand Down Expand Up @@ -218,7 +219,7 @@ describe("when the uglify-js middleware is used by connect", function() {
beforeEach(function() {
var middlewareStub = function(request,response,next){response.end();};
this.middlewareSpy = jasmine.createSpy("middleware").andCallFake(middlewareStub);
this.server.use(this.middlewareSpy);
this.connect.use(this.middlewareSpy);
});
beforeEach(function() {
this.pathname = "/abc/xyz/a.css";
Expand Down Expand Up @@ -260,7 +261,7 @@ describe("when the uglify-js middleware is used by connect", function() {
beforeEach(function() {
var middlewareStub = function(request,response,next){response.end();};
this.middlewareSpy = jasmine.createSpy("middleware").andCallFake(middlewareStub);
this.server.use(this.middlewareSpy);
this.connect.use(this.middlewareSpy);
this.pathname = "/abc/xyz/post.js";
});
it("should ignore the request invoking the next middleware", function() {
Expand All @@ -274,7 +275,7 @@ describe("when the uglify-js middleware is used by connect", function() {
beforeEach(function() {
var middlewareStub = function(request,response,next){response.end();};
this.middlewareSpy = jasmine.createSpy("middleware").andCallFake(middlewareStub);
this.server.use(this.middlewareSpy);
this.connect.use(this.middlewareSpy);
});
describe("when the request path escapes the root path", function() {
beforeEach(function() {
Expand Down

0 comments on commit 3e6caa3

Please sign in to comment.