Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Execute command on each request

  • Loading branch information...
commit 75b6564e595ecb8144dad8d7e18898753d2e6ba4 1 parent 70cbf99
@scttnlsn scttnlsn authored
Showing with 10 additions and 0 deletions.
  1. +1 −0  Readme.md
  2. +9 −0 bin/serve
View
1  Readme.md
@@ -28,6 +28,7 @@ Options:
-L, --no-logs disable request logging
-D, --no-dirs disable directory serving
--compress gzip or deflate the response
+ --exec <cmd> execute command on each request
-h, --help output usage information
```
View
9 bin/serve
@@ -6,6 +6,7 @@
var resolve = require('path').resolve
, join = require('path').join
+ , exec = require('child_process').exec
, program = require('commander')
, connect = require('connect')
, stylus = require('stylus')
@@ -31,6 +32,7 @@ program
.option('-f, --favicon <path>', 'serve the given favicon')
.option('-C, --cors', 'allows cross origin access serving')
.option(' --compress', 'gzip or deflate the response')
+ .option(' --exec <cmd>', 'execute command on each request')
.parse(process.argv);
// path
@@ -97,6 +99,13 @@ if (program.compress) {
server.use(connect.compress());
}
+// exec command
+if (program.exec) {
+ server.use(function (req, res, next){
+ exec(program.exec, next);
+ });
+}
+
// static files
server.use(connect.static(path, { hidden: program.hidden }));
Please sign in to comment.
Something went wrong with that request. Please try again.