UNPKG

688 Btext/coffeescriptView Raw
1#!/usr/bin/env coffee
2
3cli = require 'cli'
4
5cli.enable('daemon','status')
6 .setUsage('static.coffee [OPTIONS]')
7
8cli.parse {
9 log: ['l', 'Enable logging']
10 port: ['p', 'Listen on this port', 'number', 8080]
11 serve: [false, 'Serve static files from PATH', 'path', './public']
12}
13
14middleware = []
15
16cli.main (args, options) ->
17
18 if options.log
19 @debug 'Enabling logging'
20 middleware.push require('creationix/log')()
21
22 @debug 'Serving files from ' + options.serve
23 middleware.push require('creationix/static')('/', options.serve, 'index.html')
24
25 server = @createServer(middleware).listen options.port
26
27 @ok 'Listening on port ' + options.port
\No newline at end of file