Comparing version 2.4.1 to 2.5.0
@@ -9,17 +9,31 @@ var fs = require('fs') | ||
var c = read('.') | ||
c.__proto__ = read(process.env.HOME || process.env.USERPROFILE) | ||
module.exports = function(main, opts) { | ||
var dir = main ? path.dirname(main) : '.' | ||
var c = read(dir) | ||
module.exports = { | ||
vm : c.vm !== false, | ||
fork : c.fork !== false, | ||
notify : c.notify !== false, | ||
deps : c.deps, | ||
timestamp : c.timestamp || (c.timestamp !== false && 'HH:MM:ss'), | ||
clear : !!c.clear, | ||
dedupe : !!c.dedupe, | ||
extensions : c.extensions || { | ||
coffee: "coffee-script/register", | ||
ls: "LiveScript" | ||
c.__proto__ = read(process.env.HOME || process.env.USERPROFILE) | ||
// Truthy == --all-deps, false: one level of deps | ||
if (typeof c.deps != 'number') c.deps = c.deps ? -1 : 1 | ||
if (opts) { | ||
// Overwrite with CLI opts ... | ||
if (opts.allDeps) c.deps = -1 | ||
if (opts.noDeps) c.deps = 0 | ||
if (opts.dedupe) c.dedupe = true | ||
} | ||
return { | ||
vm : c.vm !== false, | ||
fork : c.fork !== false, | ||
notify : c.notify !== false, | ||
deps : c.deps, | ||
timestamp : c.timestamp || (c.timestamp !== false && 'HH:MM:ss'), | ||
clear : !!c.clear, | ||
dedupe : !!c.dedupe, | ||
extensions : c.extensions || { | ||
coffee: "coffee-script/register", | ||
ls: "LiveScript" | ||
} | ||
} | ||
} |
@@ -0,6 +1,8 @@ | ||
var resolve = require('resolve').sync | ||
/** | ||
* Look for an argument with the given name and remove it if found. | ||
* Returns `true` if the argument is found, the `defautlValue` value otherwise. | ||
* Returns `true` if the argument is found, `false` otherwise. | ||
*/ | ||
function option(args, name, defaultValue) { | ||
function option(args, name) { | ||
var i = args.indexOf(name) | ||
@@ -11,17 +13,10 @@ if (~i) { | ||
} | ||
return defaultValue | ||
return false | ||
} | ||
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 | ||
exports.parseOpts = function(args) { | ||
return { | ||
deps: deps, | ||
dedupe: option(args, '--dedupe', defaults.dedupe) | ||
allDeps: option(args, '--all-deps'), | ||
noDeps: option(args, '--no-deps'), | ||
dedupe: option(args, '--dedupe') | ||
} | ||
@@ -36,5 +31,12 @@ } | ||
args.splice(i, 0, script) | ||
break | ||
return exports.resolveMain(args[i+1]) | ||
} | ||
} | ||
} | ||
exports.resolveMain = function(main) { | ||
return resolve(main, { | ||
basedir: process.cwd(), | ||
paths: [process.cwd()] | ||
}) | ||
} |
@@ -6,3 +6,2 @@ var fork = require('child_process').fork | ||
, notify = require('./notify') | ||
, cfg = require('./cfg') | ||
, cli = require('./cli') | ||
@@ -17,10 +16,12 @@ , log = require('./log') | ||
// Parse command line options | ||
var opts = cli.parseOpts(args, cfg) | ||
var cliOpts = cli.parseOpts(args) | ||
// Inject wrap.js into the args array | ||
var main = cli.injectScript(args, __dirname + '/wrap.js') | ||
var cfg = require('./cfg')(main, cliOpts) | ||
// Run ./dedupe.js as prelaod script | ||
if (opts.dedupe) process.env.NODE_DEV_PRELOAD = __dirname + '/dedupe' | ||
if (cfg.dedupe) process.env.NODE_DEV_PRELOAD = __dirname + '/dedupe' | ||
// Inject wrap.js into the args array | ||
cli.injectScript(args, __dirname + '/wrap.js') | ||
var watcher = filewatcher() | ||
@@ -47,3 +48,3 @@ | ||
log.info('Run ulimit -n 10000 to increase the file descriptor limit.') | ||
if (opts.deps) log.info('... or add `--no-deps` to use less file handles.') | ||
if (cfg.deps) log.info('... or add `--no-deps` to use less file handles.') | ||
}) | ||
@@ -66,3 +67,3 @@ | ||
ipc.on(child, 'required', function(m) { | ||
if (opts.deps == -1 || getLevel(m.required) <= opts.deps) { | ||
if (cfg.deps == -1 || getLevel(m.required) <= cfg.deps) { | ||
watcher.add(m.required) | ||
@@ -69,0 +70,0 @@ } |
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') | ||
@@ -11,2 +13,7 @@ // Remove wrap.js from the argv array | ||
// Resolve the location of the main script relative to cwd | ||
var main = cli.resolveMain(process.argv[1]) | ||
var cfg = require('./cfg')(main) | ||
// Set NODE_ENV to 'development' unless already set | ||
@@ -45,5 +52,2 @@ if (!process.env.NODE_ENV) process.env.NODE_ENV = 'development' | ||
// Resolve the location of the main script relative to cwd | ||
var main = path.resolve(process.cwd(), process.argv[1]) | ||
// Check if a module is registered for this extension | ||
@@ -53,5 +57,5 @@ var ext = path.extname(main).slice(1) | ||
if (mod) require(mod) | ||
if (mod) require(resolve(mod, { basedir: path.dirname(main) })) | ||
// Execute the wrapped script | ||
require(main) |
{ | ||
"name": "node-dev", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"description": "Restarts your app when files are modified", | ||
@@ -33,3 +33,4 @@ "keywords": [ | ||
"filewatcher": "~1.1.1", | ||
"growl": "~1.7.0" | ||
"growl": "~1.7.0", | ||
"resolve": "^1.0.0" | ||
}, | ||
@@ -36,0 +37,0 @@ "devDependencies": { |
@@ -85,4 +85,4 @@ [![Build Status](https://secure.travis-ci.org/fgnass/node-dev.png)](http://travis-ci.org/fgnass/node-dev) | ||
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 per-user settings. | ||
directory. It will also look for a `.node-dev.json` file in the same directory | ||
as the script to be run, which (if present) overwrites the per-user settings. | ||
@@ -89,0 +89,0 @@ ### Dedupe linked modules |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
18888
335
5
+ Addedresolve@^1.0.0