Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-dev

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-dev - npm Package Compare versions

Comparing version 2.1.6 to 2.2.0

4

lib/cfg.js

@@ -16,9 +16,9 @@ var fs = require('fs')

notify : c.notify !== false,
deps : c.deps !== false,
deps : c.deps,
timestamp : c.timestamp || (c.timestamp !== false && 'HH:MM:ss'),
clear : !!c.clear,
extensions : c.extensions || {
coffee: "coffee-script",
coffee: "coffee-script/register",
ls: "LiveScript"
}
}

@@ -15,4 +15,12 @@ /**

exports.parseOpts = function(args, defaults) {
var deps = defaults.deps
// truthy: --all-deps, falsy: one level
if (typeof deps != 'number') deps = deps? -1 : 1
if (option(args, '--all-deps')) deps = -1
else if (option(args, '--no-deps')) deps = 0
return {
deps: !option(args, '--no-deps', !defaults.deps)
deps: deps
}

@@ -19,0 +27,0 @@ }

@@ -21,5 +21,2 @@ var fork = require('child_process').fork

// The prefix of the main module
var mainPrefix = getPrefix(path.resolve(args[1]))
var watcher = filewatcher()

@@ -64,3 +61,3 @@

ipc.on(child, 'required', function(m) {
if (opts.deps || getPrefix(m.required) == mainPrefix) {
if (opts.deps == -1 || getLevel(m.required) <= opts.deps) {
watcher.add(m.required)

@@ -91,2 +88,11 @@ }

/**
* Returns the nesting-level of the given module.
* Will return 0 for modules from the main package or linked modules,
* a positive integer otherwise.
*/
function getLevel(mod) {
var p = getPrefix(mod)
return p.split('node_modules').length-1
}

@@ -98,4 +104,5 @@ /**

function getPrefix(mod) {
var i = mod.lastIndexOf('node_modules')
return ~i ? mod.slice(0, i) : ''
var n = 'node_modules'
var i = mod.lastIndexOf(n)
return ~i ? mod.slice(0, i+n.length) : ''
}
{
"name": "node-dev",
"version": "2.1.6",
"version": "2.2.0",
"description": "Restarts your app when files are modified",

@@ -32,3 +32,3 @@ "keywords": [

"dateformat": "~1.0.4-1.2.3",
"filewatcher": "~1.0.0"
"filewatcher": "~1.1.1"
},

@@ -38,4 +38,4 @@ "devDependencies": {

"expect.js": "~0.2.0",
"coffee-script": "~1.5.0"
"coffee-script": "~1.7.1"
}
}
[![Build Status](https://secure.travis-ci.org/fgnass/node-dev.png)](http://travis-ci.org/fgnass/node-dev)
# node-dev
### node-dev (1)
Node-dev is a development tool for [Node.js](http://nodejs.org) that
automatically restarts the node process when a script is modified.
automatically restarts the node process when a file is modified.
It's an alternative to tools like
In contrast to tools like
[supervisor](https://github.com/isaacs/node-supervisor) or
[nodemon](https://github.com/remy/nodemon) that doesn't require any
configuration. Just run `node-dev foo.js` as you would normally run `node` and
it will automatically figure out which files need to be watched.
[nodemon](https://github.com/remy/nodemon) it doesn't scan the filesystem for
files to be watched. Instead it hooks into Node's `require()` function to watch
only the files that have been _actually required_.
You may also use node-dev with [CoffeeScript](http://http://coffeescript.org/)
or [LiveScript](http://livescript.net/) apps. Just run `node-dev app.coffee`
or `node-dev app.ls`. You may also register additional language flavors by
adding them to the extensions list in your [.node-dev.json](#settings) config
file.
This means that you don't have to configure any include- or exclude rules.
If you modify a JS file that is solely used on the client-side but never run on
the server, __node-dev will know__ this and won't restart the process.
This also means that you __don't have to__ configure any file extensions. Just
require a `.json` file or a `.coffee` script for example and it will be watched.
Automatically.
Node-dev uses [filewatcher](https://www.npmjs.org/package/filewatcher) under
the hood and hence will take advantage of the native `fs.watch()` API if it
is available on your system.
# Usage
Just run `node-dev` as you would normally run `node`:
```
node-dev foo.js
```
There are two command line options that can be used to control how many files
are watched:
* `--no-deps` Watch only the project's own files and linked modules (via `npm link`)
* `--all-deps` Watch the whole dependency tree
By default node-dev will watch all first-level dependencies, i.e. the ones in
the project's `node_modules`folder.
# Installation
Node-dev can be installed via npm. Make sure to use the `-g` option to install
it globally.
npm install -g node-dev
### Desktop Notifications

@@ -30,8 +62,3 @@

### Installation
Node-dev can be installed via [npm](http://github.com/isaacs/npm):
npm install -g node-dev
In order to use Growl notifications

@@ -45,21 +72,47 @@ [growlnotify](http://growl.info/extras.php#growlnotify) must be installed on

### Settings
# Settings
Usually node-dev doesn't require any configuration at all, but there are some
options you can set to tweak its behaviour:
* `clear` – Whether to clear the screen upon restarts. _Default:_ `false`
* `notify` – Whether to display desktop notifications. _Default:_ `true`
* `timestamp` – The timestamp format to use for logging restarts. _Default:_ `"HH:MM:ss"`
* `vm` – Whether to watch files loaded via Node's [VM](http://nodejs.org/docs/latest/api/vm.html) module. _Default:_ `true`
* `fork` – Whether to hook into [child_process.fork](http://nodejs.org/docs/latest/api/child_process.html#child_process_child_process_fork_modulepath_args_options) (required for [clustered](http://nodejs.org/docs/latest/api/cluster.html) programs). _Default:_ `true`
* `deps` - How many levels of dependencies should be watched. _Default:_ `1`
Upon startup node-dev looks for a `.node-dev.json` file in the user's HOME
directory. It will also look for a `.node-dev.json` file in the current
directory which – if present – overwrites the global settings.
directory which (if present) overwrites the per-user settings.
* __vm__ – Whether to watch files loaded via Node's [VM](http://nodejs.org/docs/latest/api/vm.html) module. _Default:_ `true`
* __fork__ – Whether to hook into [child_process.fork()](http://nodejs.org/docs/latest/api/child_process.html#child_process_child_process_fork_modulepath_args_options) which is required for [clustered](http://nodejs.org/docs/latest/api/cluster.html) programs. _Default:_ `true`
* __notify__ – Whether to display desktop notifications. _Default:_ `true`
* __timestamp__ – The timestamp format to use for logging restarts. _Default:_ `"HH:MM:ss"`
* __clear__ – Whether to clear the screen upon restarts. _Default:_ `false`
* __extensions__ – Modules to load based bad on extension of the main script. _Default:_
`{ coffee: "coffee-script", ls: "LiveScript" }`
* __deps__ - Wether to watch dependencies of a project (modules which reside in
`node_modules` directories). _Default:_ `true`
### Transpilers
You can also use node-dev to run transpiled languages. You can either use a
.js file as entry point to your application that registers your transpiler as
require-extension manually, for example by calling `CoffeeScript.register()` or
you can let node-dev do this for you.
There is a config option called `extensions` which maps file extensions to
compiler module names. By default this map looks like this:
```json
{
"coffee": "coffee-script/register",
"ls": "LiveScript"
}
```
This means that if you run `node-dev foo.coffee` node-dev will do a
`require("coffee-script/register")` before running your script.
__Note:__ If you want to use coffee-script < 1.7 you have to change the
setting to `{"coffee": "coffee-script"}`.
## License
### The MIT License (MIT)
Copyright (c) 2013 Felix Gnass
Copyright (c) 2014 Felix Gnass

@@ -66,0 +119,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc