Permalink
Browse files

Changes the code style

  • Loading branch information...
1 parent 65337c7 commit 660d61a526361b7be7e76fa9b13c18b396c572cf @phstc phstc committed Aug 26, 2012
Showing with 30 additions and 24 deletions.
  1. +29 −23 bin/cli.js
  2. +1 −1 package.json
View
@@ -3,10 +3,9 @@
var fs = require('fs'),
path = require('path'),
tty = require('tty'),
+ statik = require('./../lib/node-static');
- statik = require('./../lib/node-static'),
-
- argv = require('optimist')
+ var argv = require('optimist')
.usage([
'USAGE: $0 [-p <port>] [<directory>]',
'simple, rfc 2616 compliant file streaming module for node']
@@ -36,47 +35,54 @@ var fs = require('fs'),
alias: 'h',
description: 'display this help message'
})
- .argv,
- dir = argv._[0] || '.',
+ .argv;
+
+ var dir = argv._[0] || '.';
- trainwreck = fs.readFileSync(path.join(__dirname, '../etc/trainwreck.jpg')),
- notFound = fs.readFileSync(path.join(__dirname, '../etc/404.html'))
+ var trainwreck = fs.readFileSync(path.join(__dirname, '../etc/trainwreck.jpg')),
+ notFound = fs.readFileSync(path.join(__dirname, '../etc/404.html'))
.toString()
- .replace('{{trainwreck}}', trainwreck.toString('base64')),
+ .replace('{{trainwreck}}', trainwreck.toString('base64'));
+
+ var colors = require('colors');
- colors = require('colors'),
- log = function(request, response, statusCode) {
- var d = new(Date),
- seconds = d.getSeconds() < 10? '0'+d.getSeconds() : d.getSeconds(),
+ var log = function(request, response, statusCode) {
+ var d = new Date();
+ var seconds = d.getSeconds() < 10? '0'+d.getSeconds() : d.getSeconds(),
datestr = d.getHours() + ':' + d.getMinutes() + ':' + seconds,
line = datestr + ' [' + response.statusCode + ']: ' + request.url,
colorized = line;
if (tty.isatty(process.stdout.fd))
- colorized = response.statusCode >= 500? line.red.bold :
- response.statusCode >= 400? line.red :
+ colorized = (response.statusCode >= 500) ? line.red.bold :
+ (response.statusCode >= 400) ? line.red :
line;
console.log(colorized);
- },
+ };
- file, options;
+ var file, options;
-if (argv.help)
- require('optimist').showHelp(console.log),
+if (argv.help){
+ require('optimist').showHelp(console.log);
process.exit(0);
+}
-if (argv.version)
- console.log('node-static', statik.version.join('.')),
+if (argv.version){
+ console.log('node-static', statik.version.join('.'));
process.exit(0);
+}
-if (argv.cache)
+if (argv.cache){
(options = options || {}).cache = argv.cache;
+}
-if (argv.headers)
+if (argv.headers){
(options = options || {}).headers = JSON.parse(argv.headers);
+}
-if (argv['header-file'])
+if (argv['header-file']){
(options = options || {}).headers =
JSON.parse(fs.readFileSync(argv['header-file']));
+}
file = new(statik.Server)(dir, options);
View
@@ -30,7 +30,7 @@
"request": "latest",
"vows": "latest"
},
- "version" : "0.6.0",
+ "version" : "0.6.1",
"engines" : { "node": ">= 0.4.1" }
}

0 comments on commit 660d61a

Please sign in to comment.