Permalink
Browse files

Added a node-based web server.

  • Loading branch information...
1 parent ab0b72c commit 6f81a652ead96d7609773d08f8dab31054130c5e @modeswitch modeswitch committed Nov 10, 2012
Showing with 46 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +11 −0 Jakefile
  3. +2 −1 package.json
  4. +14 −0 tools/jake-tasks/default.js
  5. +18 −0 tools/jake-tasks/serve.js
View
@@ -0,0 +1 @@
+node_modules
View
@@ -0,0 +1,11 @@
+var PATH = process.env["PATH"].split( ':' );
+var MODULES_BIN = process.cwd() + "/node_modules/.bin";
+PATH.unshift( MODULES_BIN );
+PATH = PATH.join( ':' );
+
+process.env["PATH"] = PATH;
+
+task( "default", [], require( "./tools/jake-tasks/default" ) );
+
+desc( "start web server in project directory" );
+task( "serve", [], require( "./tools/jake-tasks/serve" ) );
View
@@ -5,7 +5,8 @@
"description": "requirejs optimization script",
"main": "build-require.js",
"dependencies": {
- "requirejs": "~2.x"
+ "requirejs": "~2.x",
+ "connect": "~2.4.2"
},
"scripts": {
"start": "node build-require.js"
@@ -0,0 +1,14 @@
+module.exports = function() {
+ var cmds = [
+ "jake -T"
+ ];
+ var callback = function() {
+ };
+ var opts = {
+ stdout: true,
+ stderr: true,
+ breakOnError: false
+ };
+
+ jake.exec( cmds, callback, opts );
+};
View
@@ -0,0 +1,18 @@
+var connect = require( "connect" );
+
+module.exports = function( port, base ) {
+ port = port || 1337;
+ base = base || process.cwd();
+
+ var middleware = [
+ connect.static( base ),
+ connect.directory( base )
+ ];
+
+ connect.logger.format( "thimble", ("[D] server :method :url :status " +
+ ":res[content-length] - :response-time ms" ));
+ middleware.unshift( connect.logger( "thimble" ) );
+
+ console.log( "starting web server on port " + port );
+ connect.apply( null, middleware ).listen( port );
+};

0 comments on commit 6f81a65

Please sign in to comment.