Comparing version
var fs = require('fs') | ||
, path = require('path') | ||
var path = require('path') | ||
@@ -4,0 +4,0 @@ function read(dir) { |
var vm = require('vm') | ||
, cfg = require('./cfg') | ||
module.exports = function(wrapper, callback) { | ||
module.exports = function(cfg, wrapper, callback) { | ||
@@ -6,0 +5,0 @@ // Hook into Node's `require(...)` |
var fork = require('child_process').fork | ||
, path = require('path') | ||
, filewatcher = require('filewatcher') | ||
, ipc = require('./ipc') | ||
, notify = require('./notify') | ||
, cli = require('./cli') | ||
, log = require('./log') | ||
var path = require('path') | ||
var filewatcher = require('filewatcher') | ||
var ipc = require('./ipc') | ||
var cli = require('./cli') | ||
@@ -15,3 +13,3 @@ module.exports = function(args) { | ||
// Parse command line options | ||
var cliOpts = cli.parseOpts(args) | ||
var opts = cli.parseOpts(args) | ||
@@ -21,3 +19,5 @@ // Inject wrap.js into the args array | ||
var cfg = require('./cfg')(main, cliOpts) | ||
var cfg = require('./cfg')(main, opts) | ||
var log = require('./log')(cfg) | ||
var notify = require('./notify')(cfg, log) | ||
@@ -24,0 +24,0 @@ // Run ./dedupe.js as prelaod script |
@@ -1,11 +0,4 @@ | ||
var cfg = require('./cfg') | ||
, util = require('util') | ||
, fmt = require('dateformat') | ||
var util = require('util') | ||
var fmt = require('dateformat') | ||
/** | ||
* Logs a message to the console. The level is displayed in ANSI colors, | ||
* either bright red in case of an error or green otherwise. | ||
*/ | ||
module.exports = exports = log | ||
var colors = { | ||
@@ -17,22 +10,31 @@ info: '36', | ||
function log(msg, level) { | ||
if (cfg.timestamp) msg = color(fmt(cfg.timestamp), '30;1') + ' ' + msg | ||
var c = colors[level.toLowerCase()] || '32' | ||
console.log('[' + color(level.toUpperCase(), c) +'] ' + msg) | ||
} | ||
/** | ||
* Logs a message to the console. The level is displayed in ANSI colors, | ||
* either bright red in case of an error or green otherwise. | ||
*/ | ||
module.exports = function(cfg) { | ||
function color(s, c) { | ||
return '\x1B[' + c + 'm' + s + '\x1B[0m' | ||
} | ||
function log(msg, level) { | ||
if (cfg.timestamp) msg = color(fmt(cfg.timestamp), '30;1') + ' ' + msg | ||
var c = colors[level.toLowerCase()] || '32' | ||
console.log('[' + color(level.toUpperCase(), c) +'] ' + msg) | ||
} | ||
exports.info = function() { | ||
log(util.format.apply(util, arguments), 'info') | ||
} | ||
function color(s, c) { | ||
return '\x1B[' + c + 'm' + s + '\x1B[0m' | ||
} | ||
exports.warn = function() { | ||
log(util.format.apply(util, arguments), 'warn') | ||
log.info = function() { | ||
log(util.format.apply(util, arguments), 'info') | ||
} | ||
log.warn = function() { | ||
log(util.format.apply(util, arguments), 'warn') | ||
} | ||
log.error = function() { | ||
log(util.format.apply(util, arguments), 'error') | ||
} | ||
return log | ||
} | ||
exports.error = function() { | ||
log(util.format.apply(util, arguments), 'error') | ||
} |
@@ -1,17 +0,21 @@ | ||
var growl = require('growl') | ||
, path = require('path') | ||
, cfg = require('./cfg') | ||
, log = require('./log') | ||
var path = require('path') | ||
var notifier = require('node-notifier') | ||
function icon(level) { | ||
return path.resolve(__dirname, '../icons/node_' + level + '.png') | ||
} | ||
/** | ||
* Displays a desktop notification and writes a message to the console. | ||
*/ | ||
module.exports = function(title, msg, level) { | ||
level = level || 'info' | ||
log(title || msg, level) | ||
if (cfg.notify) growl(msg, { title: title || 'node.js', image: icon(level) }) | ||
module.exports = function(cfg, log) { | ||
return function(title, msg, level) { | ||
level = level || 'info' | ||
log(title || msg, level) | ||
if (cfg.notify) notifier.notify({ | ||
title: title || 'node.js', | ||
image: icon(level), | ||
message: msg | ||
}) | ||
} | ||
} | ||
function icon(level) { | ||
return path.resolve(__dirname, '../icons/node_' + level + '.png') | ||
} |
var path = require('path') | ||
, child_process = require('child_process') | ||
, fork = child_process.fork | ||
, resolve = require('resolve').sync | ||
, hook = require('./hook') | ||
, ipc = require('./ipc') | ||
, cfg = require('./cfg') | ||
, cli = require('./cli') | ||
var child_process = require('child_process') | ||
var fork = child_process.fork | ||
var resolve = require('resolve').sync | ||
var hook = require('./hook') | ||
var ipc = require('./ipc') | ||
var cfg = require('./cfg') | ||
var cli = require('./cli') | ||
@@ -47,3 +47,3 @@ // Remove wrap.js from the argv array | ||
// Hook into require() and notify the parent process about required files | ||
hook(module, function(file) { | ||
hook(cfg, module, function(file) { | ||
ipc.send({required: file}) | ||
@@ -50,0 +50,0 @@ }) |
{ | ||
"name": "node-dev", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Restarts your app when files are modified", | ||
@@ -33,3 +33,3 @@ "keywords": [ | ||
"filewatcher": "~1.1.1", | ||
"growl": "~1.7.0", | ||
"node-notifier": "^4.0.2", | ||
"resolve": "^1.0.0" | ||
@@ -36,0 +36,0 @@ }, |
@@ -54,5 +54,4 @@ [](http://travis-ci.org/fgnass/node-dev) | ||
Status and error messages can be displayed as desktop notification using either | ||
[Growl](http://growl.info/about.php) or | ||
[libnotify](http://developer.gnome.org/libnotify/). | ||
Status and error messages can be displayed as desktop notification using | ||
[node-notifier](https://www.npmjs.org/package/node-notifier): | ||
@@ -63,11 +62,10 @@  | ||
__Requirements:__ | ||
In order to use Growl notifications | ||
[growlnotify](http://growl.info/extras.php#growlnotify) must be installed on | ||
your system. | ||
* Mac OS X: >= 10.8 or Growl if earlier. | ||
* Linux: notify-osd installed (Ubuntu should have this by default) | ||
* Windows: >= 8, task bar balloon if earlier or Growl if that is installed. | ||
* General Fallback: Growl | ||
To use OSX's built in notifications: | ||
sudo gem install terminal-notifier | ||
# Settings | ||
@@ -74,0 +72,0 @@ |
18932
0.23%340
1.49%149
-1.32%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed