Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ function Loader(dirpath, opt) {
this.opt.call = this.opt.call !== false;
this.opt.override = this.opt.override === true;
this._mods = [];
this.concat(dirpath);

if (Array.isArray(dirpath)) {
for (var i = 0, l = dirpath.length; i < l; i++) {
this.concat(dirpath[i]);
}
} else {
this.concat(dirpath);
}
}

var proto = Loader.prototype;
Expand All @@ -39,7 +46,6 @@ proto._load = function (target, field, options) {
var mods = this._mods;
var isCall = this.opt.call;
var isOverride = this.opt.override;
var self = this;

if (!target) {
return;
Expand All @@ -49,7 +55,6 @@ proto._load = function (target, field, options) {
target[field] = {};
}

var map = {};
mods.forEach(function (item, index) {
var properties = item.properties;
if (filters && filters.length > 0 && filters.indexOf(properties[0]) === -1) {
Expand Down
8 changes: 8 additions & 0 deletions test/loading.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ describe('loading.test.js', function () {
.into(app, 'services');
});

it('should overwrite property from loading using array', function() {
var app = {};
loading([
path.join(__dirname, 'fixtures', 'services'),
path.join(__dirname, 'fixtures', 'overwrite_services')
], {override: true}).into(app, 'services');
});

it('should just return when no target', function() {
loading(path.join(__dirname, 'fixtures', 'services')).into();
});
Expand Down