Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added extensions

  • Loading branch information...
commit 768beaaa3c1dc8ebc5cdd61fd5227140436d29b4 1 parent ecae588
stagas authored
Showing with 17 additions and 11 deletions.
  1. +6 −4 README.md
  2. +10 −6 nolife.js
  3. +1 −1  package.json
10 README.md
View
@@ -13,9 +13,11 @@ Installation
Usage
-----
- nolife <dir> <program> [param] [...]
+ nolife <dirname_to_watch> <ext,ens,ion,s,to,wa,tch> <program> [param] [...]
-Example
--------
+Examples
+--------
- nolife . node app
+ nolife . . node app
+ nolife views jade node app
+ nolife server js,json,jade node server/app.js
16 nolife.js
View
@@ -14,8 +14,8 @@ var util = require('util')
, proc
, watched = []
-if (process.argv.length <= 2) {
- console.log('usage: nolife <dir> <program> [param] [...]')
+if (process.argv.length <= 4) {
+ console.log('usage: nolife <dirname_to_watch> <ext,ens,ion,s,to,wa,tch> <program> [param] [...]')
process.exit()
}
@@ -27,11 +27,14 @@ function log() {
console.log.apply(console, args)
}
+var extensions = process.argv[3].toLowerCase().split(',')
+log('watching extensions:', extensions[0] == '.' ? '*' : '.' + extensions.join(' .'))
+
;(function respawn(app) {
var restartTimeout
, filename = path.join(process.cwd(), app[0])
, dirname = path.resolve(filename)
- , args = app.slice(2)
+ , args = app.slice(3)
;(function cleanWatch() {
var file
@@ -58,6 +61,7 @@ function log() {
Walker(dirname)
.on('file', function(file) {
+ if (!~extensions.indexOf(path.extname(file).slice(1).toLowerCase()) && !~extensions.indexOf('.')) return
watched.push(file)
fs.watchFile(file, function(curr, prev) {
if (curr.mtime != prev.mtime) {
@@ -71,11 +75,11 @@ function log() {
log('got error ' + er + ' on target ' + target)
})
- log('watching:', dirname)
- log('starting:', app[1], args.join(' '))
+ log('watching dir:', dirname)
+ log('starting:', app[2], args.join(' '))
try {
- proc = child_process.spawn(app[1], args)
+ proc = child_process.spawn(app[2], args)
} catch(e) {
log('failed to run', app.join(' '), '\n', util.inspect(e))
log('trying again in 2 seconds...')
2  package.json
View
@@ -1,6 +1,6 @@
{ "name" : "nolife"
, "description" : "nolife restarts an application if a file changes"
-, "version" : "0.0.1"
+, "version" : "0.0.2"
, "homepage" : "https://github.com/stagas/nolife"
, "author" : "George Stagas <gstagas@gmail.com> (http://stagas.com/)"
, "repository" :
Please sign in to comment.
Something went wrong with that request. Please try again.