static-cling
Advanced tools
Comparing version 0.0.3 to 0.0.4
#!/usr/bin/env node | ||
console.log('starting static file server'); | ||
var path = require('path'), | ||
@@ -7,3 +6,4 @@ argv = require('optimist').argv, | ||
port = 3000, | ||
dir = '.'; | ||
dir = '.', | ||
file = 'index.html'; | ||
@@ -16,6 +16,9 @@ if(argv.p){ | ||
} | ||
if(argv.f){ | ||
file = argv.f; | ||
} | ||
path.exists(dir, function (exists) { | ||
if(exists){ | ||
console.log('starting to serve files in ' + dir + ' on port ' + port); | ||
cling(port, dir); | ||
cling(port, dir, file); | ||
}else{ | ||
@@ -22,0 +25,0 @@ console.log('Directory does not exist'); |
@@ -7,4 +7,3 @@ var path = require('path'), | ||
var cling = function(port,rootPath){ | ||
var cling = function(port,rootPath, defaultFilename){ | ||
if(rootPath===undefined){ | ||
@@ -16,2 +15,6 @@ rootPath = '.'; | ||
} | ||
if(defaultFilename === undefined){ | ||
defaultFilename = 'index.html'; | ||
} | ||
http.createServer(function (req, res) { | ||
@@ -25,3 +28,3 @@ var uri = url.parse(req.url).pathname; | ||
}); | ||
res.write('404 Not Found\n'); | ||
res.write('404 - File Not Found\n'); | ||
res.end(); | ||
@@ -32,3 +35,3 @@ return; | ||
if (fs.statSync(filename).isDirectory()) { | ||
filename += '/index.html'; | ||
filename = path.join(filename, defaultFilename); | ||
} | ||
@@ -55,3 +58,3 @@ | ||
}).listen(port); | ||
} | ||
}; | ||
exports.cling = cling; |
{ "name": "static-cling" | ||
, "version": "0.0.3" | ||
, "version": "0.0.4" | ||
, "engines": [ "node >=0.6.0" ] | ||
@@ -4,0 +4,0 @@ , "description": "Static file server" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
2907
7
77
0
1