🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

servit

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

servit - npm Package Compare versions

Comparing version
0.2.0
to
0.3.0
+9
-9
package.json
{
"name": "servit",
"preferGlobal": "true",
"version": "0.2.0",
"version": "0.3.0",
"description": "The stupid development server. Serves CoffeeScript, EJS, and Stylus like a champ. Reloads browser on source-file change.",

@@ -19,11 +19,11 @@ "keywords": ["assets", "serve", "static", "watch"],

"dependencies": {
"coffee-script": "*",
"commander": "*",
"connect": "*",
"hound": "*",
"ejs": "*",
"snockets": "*",
"socket.io": "*",
"stylus": "*"
"coffee-script": "1.*",
"commander": "1.*",
"connect": "2.*",
"ejs": "0.8.*",
"snockets": "1.*",
"stylus": "0.30.*",
"socket.io": "0.9.*",
"watchr": "2.*"
}
}
+33
-32

@@ -7,9 +7,9 @@ servit

- Reloads browser on source-file change.
- Serves [CoffeeScript][coff], [EJS][ejs], and [Stylus][styl] like a champ.
- Serves [CoffeeScript][coffee], [EJS][ejs], and [Stylus][stylus] like a champ.
- Compiled output sent directly to browser for a pristine working directory.
- No caching so you're guaranteed to get the latest changes.
- No preprocessor caching so you're guaranteed to load the freshest code.
Built with [Connect][conn], [Socket.io][sock], [Commander.js][comm], and
[hound][houn]. Inspired by visionmedia's [serve][serv] and nodejitsu's
[http-server][hser].
Built with [Connect][connect], [Socket.io][socket-io], [Commander.js][commander], and
[watchr][watchr]. Inspired by visionmedia's [serve][serve] and nodejitsu's
[http-server][http-server].

@@ -27,3 +27,2 @@ Installation

```
Usage: servit [options] [dir]

@@ -55,3 +54,2 @@

Serving /var/www/foo at http://192.168.0.1:8080/
```

@@ -66,13 +64,15 @@

the output directly to the browser. No rendered files are written to disk, so
your working directory is left in a pristine state (I'm looking at you
[connect-assets][coas]).
your working directory is left in a pristine state.
File extensions are taken literally. If you request `.ejs`, you'll get EJS:
```
`$ curl http://localhost:3000/foo.ejs`:
$ curl http://localhost:3000/foo.ejs
<!DOCTYPE html><title>Hello world</title><link rel="stylesheet" href="foo.css"><script src="/connect-reload.js"></script><script src="foo.js"></script>
```html
<!DOCTYPE html>
<title>Hello world</title>
<link rel="stylesheet" href="foo.css">
<script src="connect-reload.js"></script>
<script src="foo.js"></script>
<% include someAnotherTemplate %>
```

@@ -83,7 +83,11 @@

```
`$ curl http://localhost:3000/foo.html`:
$ curl http://localhost:3000/foo.html
<!DOCTYPE html><title>Hello world</title><link rel="stylesheet" href="foo.css"><script src="/connect-reload.js"></script><script src="foo.js"></script>
```html
<!DOCTYPE html>
<title>Hello world</title>
<link rel="stylesheet" href="foo.css">
<script src="connect-reload.js"></script>
<script src="foo.js"></script>
<p>Some another template content</p>
```

@@ -96,10 +100,8 @@

To enable automatic reloading of a page when a file in your project is created
or changed, simply include the virtual `/connect-reload.js` in your markup:
or changed, simply include the virtual `connect-reload.js` in your markup:
```html
<script src="connect-reload.js"></script>
```
<!-- HTML -->
<script src="/connect-reload.js"></script>
```
License

@@ -110,3 +112,3 @@ -------

Copyright (c) Patrik Votoček &lt;patrik@votocek.cz&gt;
Copyright (c) Patrik Votoček &lt;patrik@votocek.cz&gt;
Copyright (c) Shannon Moeller &lt;me@shannonmoeller.com&gt;

@@ -134,11 +136,10 @@

[workit]: https://github.com/shannonmoeller/workit
[coas]: https://github.com/TrevorBurnham/connect-assets
[coff]: http://coffeescript.org/
[comm]: http://visionmedia.github.com/commander.js/
[conn]: http://senchalabs.org/connect/
[houn]: https://github.com/beefsack/node-hound/
[hser]: https://github.com/nodeapps/http-server/
[coffee]: http://coffeescript.org/
[commander]: http://visionmedia.github.com/commander.js/
[connect]: http://senchalabs.org/connect/
[watchr]: https://github.com/bevry/watchr/
[http-server]: https://github.com/nodeapps/http-server/
[ejs]: https://github.com/visionmedia/ejs
[serv]: https://github.com/visionmedia/serve/
[sock]: http://socket.io/
[styl]: http://learnboost.github.com/stylus/
[serve]: https://github.com/visionmedia/serve/
[socket-io]: http://socket.io/
[stylus]: http://learnboost.github.com/stylus/
# Modules
hound = require 'hound'
path = require 'path'
socketio = require 'socket.io'
util = require 'util'
watchr = require 'watchr'

@@ -11,5 +11,5 @@ # Prozac

clearTimeout timeout
timeout = setTimeout fn, 20
timeout = setTimeout fn, 50
# Client
# Client-side script
client = ->

@@ -34,15 +34,10 @@ # Honor address and port values

# Browserify
client = "(#{client}());"
# Export middleware
module.exports = ({address, dir, port, server}) ->
# Prep client-side script
client = util.format "(#{client}());", address, port
# Start watching files and open socket
dog = hound.watch dir
io = socketio.listen server, 'log level': 0
# Watcher ignore some folders and files
for pattern in ['.svn', '.git', '.hg', 'CVS', '.DS_Store']
dog.unwatch "#{dir}/#{pattern}"
# Reasonable emitter

@@ -57,13 +52,16 @@ emit = debounce ->

# Bind handler
dog.on 'create', reload
dog.on 'change', reload
# Bind emitter to file changes
watchr.watch
ignoreHiddenFiles: true
ignorePatterns: true
listener: reload
path: dir
# Return middleware
({url}, res, next) ->
# Handle reloads
return next() unless url is '/connect-reload.js'
# Guard reload requests
return next() unless url.slice(-17) is 'connect-reload.js'
# RAM for the win
res.setHeader 'Content-Type', 'text/javascript'
res.end util.format(client, address, port)
res.end client

Sorry, the diff of this file is not supported yet