Permalink
Browse files

static dirs

  • Loading branch information...
1 parent 977fd19 commit fb0135adf434e868190798731b0bf8f3a10667cf @azer committed Jun 11, 2012
Showing with 39 additions and 6 deletions.
  1. +3 −1 lib/config.js
  2. +8 −3 lib/server.js
  3. +20 −0 lib/staticdirs.js
  4. +2 −2 package.json
  5. +4 −0 test/config.json
  6. +1 −0 test/fruits/apple
  7. +1 −0 test/fruits/orange
View
@@ -8,7 +8,7 @@ var fs = require('fs'),
dirname = path.dirname,
join = path.join,
- verify, commander, revision, server, report, userscripts;
+ verify, commander, revision, server, report, userscripts, staticdirs;
var _filename = '.lowkick',
cache = undefined;
@@ -70,13 +70,15 @@ function updateClients(){
commander = require('./commander');
revision = require('./revision');
verify = require('./verify');
+ staticdirs = require('./staticdirs');
verify.environ(cache.environ);
has('scripts') && userscripts(cache.scripts.map(function(el){ return join(dir(), el); }));
has('commands') && commander.commands(cache.commands);
has('target') && ( report.filename(join(dirname(filename()), cache.target)) );
has('logs') && ( logging.filename(join(dirname(filename()), cache.logs)) );
+ has('static') && staticdirs(cache['static']);
if(has('server')){
logging.trace('Updating server settings. Hostname: %s Port: %s', ( cache.server.hostname || cache.server.host ), cache.server.port);
View
@@ -9,6 +9,7 @@ var connect = require('connect'),
logging = require('./logging'),
userscripts = require('./userscripts'),
sandbox = require('./sandbox'),
+ staticdirs = require('./staticdirs'),
api;
var runningServer;
@@ -140,19 +141,23 @@ function start(callback){
var homepage = genHomepage(),
scripts = connect(connect.router(userscripts.router)),
- statik = connect['static'](join(__dirname, '../public')),
index = connect(connect.router(function(app){
app.get('/', homepage);
app.get('/index.html', homepage);
}));
- runningServer = connect(connect.query());
+ runningServer = connect(connect.query())
+ .use('/static', connect['static'](join(__dirname, '../public')));
+
+ var uri, statik = staticdirs();
+ for(uri in statik){
+ runningServer.use( uri, connect['static'](statik[uri]) );
+ }
runningServer
.use('/', index)
.use('/scripts', scripts)
- .use('/static', statik)
.use('/api', api)
.use(api.p404)
.listen(port());
View
@@ -0,0 +1,20 @@
+var join = require('path').join,
+ wd = require('./config').dirname;
+
+var dirs = {};
+
+function staticdirs(newValue){
+
+ var uri, path;
+ if( arguments.length > 0 ){
+
+ for(uri in newValue){
+ dirs[ join('/static', uri) ] = join( wd(), newValue[uri] );
+ }
+
+ }
+
+ return dirs;
+}
+
+module.exports = staticdirs;
View
@@ -1,13 +1,13 @@
{
"name": "lowkick",
- "version": "0.1.1",
+ "version": "0.2.0",
"description": "Simplifies running and verifying cross-browser tests on command-line.",
"author": "Azer Koculu <azer@kodfabrik.com>",
"keywords":["testing", "test"],
"directories":{ "lib": "./lib" },
"main": "./lib/lowkick.js",
"devDependencies":{
- "highkick": "1.x",
+ "highkick": "1.4.x",
"forever": "0.x"
},
"dependencies":{
View
@@ -17,6 +17,10 @@
"port": "1314"
},
+ "static":{
+ "fruits":"./fruits"
+ },
+
"scripts":[
"frontend.js"
],
View
@@ -0,0 +1 @@
+foo
View
@@ -0,0 +1 @@
+bar

0 comments on commit fb0135a

Please sign in to comment.