Skip to content

Commit

Permalink
Merge pull request #10 from Jimbly/master
Browse files Browse the repository at this point in the history
Fix global defaults getting squashed in each call to dive, and using the global defaults instead of local options.
  • Loading branch information
pvorb committed May 9, 2014
2 parents 41c061b + 06c7f16 commit 87721d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 9 additions & 2 deletions dive.js
@@ -1,6 +1,5 @@
var fs = require('fs');
var path = require('path');
var append = require('append');

// default options
var defaultOpt = {
Expand All @@ -10,6 +9,14 @@ var defaultOpt = {
directories: false
};

function defaults(defaults, obj) {
for (var prop in defaults)
if (defaults.hasOwnProperty(prop))
if (!obj.hasOwnProperty(prop))
obj[prop] = defaults[prop];
return obj;
}

// general function
module.exports = function(dir, opt, action, complete) {

Expand All @@ -29,7 +36,7 @@ module.exports = function(dir, opt, action, complete) {
if (typeof dir != 'string')
dir = process.cwd();

opt = append(defaultOpt, opt);
opt = defaults(defaultOpt, opt);

function dive(dir) {
// Read the directory
Expand Down
7 changes: 3 additions & 4 deletions package.json
Expand Up @@ -5,7 +5,8 @@
"contributors": [
"Jasper Palfree (https://github.com/wellcaffeinated)",
"Jan Mühlemann (https://github.com/jamuhl)",
"Axel Hecht <axel@pike.org> (http://blog.mozilla.com/axel/)"
"Axel Hecht <axel@pike.org> (http://blog.mozilla.com/axel/)",
"Jimb Esser (https://github.com/Jimbly)"
],
"version": "0.3.0",
"main": "dive.js",
Expand All @@ -25,9 +26,7 @@
"engines": {
"node": ">=0.4.0"
},
"dependencies": {
"append": ">=0.1.1"
},
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {}
}

0 comments on commit 87721d8

Please sign in to comment.