Skip to content

Commit

Permalink
- code styling
Browse files Browse the repository at this point in the history
- increased minor version to 2.13.0
  • Loading branch information
Christopher Knötschke committed Apr 27, 2016
1 parent 6cb3481 commit e738462
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions lib/package_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ PackageCollection.prototype = {
addDependencies: function (dependencies, group, bowerJson) {
if (typeof dependencies !== "string") {
var deps = (!!group) ? this.filterByGroup(dependencies, group, bowerJson) : dependencies;

for (var name in deps) {
this.add(name, path.join(this.opts.paths.bowerDirectory, path.sep, name));
}
Expand All @@ -119,8 +120,10 @@ PackageCollection.prototype = {
*/
filterByGroup: function (deps, group, bowerJson) {
var filtered = {};

if (typeof group === "string") {
var isExludingGroup = (group && bowerJson.group && group.charAt(0) === "!" && bowerJson.group[group.slice(1)].length > 0);

for (var dep in deps) {
if (isExludingGroup && bowerJson.group[group.slice(1)].indexOf(dep) === -1) {
filtered[dep] = deps[dep];
Expand All @@ -129,30 +132,39 @@ PackageCollection.prototype = {
filtered[dep] = deps[dep];
}
}

return filtered;
}

if (typeof group === "object") {
for (var i = 0; i < group.length; i++) {
filtered = extend(filtered, this.filterByGroup(deps, group[i], bowerJson));
}
}

return filtered;
},

/**
* Calls error method if group doesn't exist
*
*/
checkGroupExists: function (group, bowerJson, error) {
if(!group || !bowerJson.group) return false;
if(!group || !bowerJson.group) {
return;
}

if (typeof group === "string") {
var isExludingGroup = (group && bowerJson.group && group.charAt(0) === "!" && bowerJson.group[group.slice(1)].length > 0);

if(!bowerJson.group[group] && !isExludingGroup) {
error(group);
return false;

return;
}

return bowerJson.group[group];
}

if (typeof group === "object") {
for (var i = 0; i < group.length; i++) {
this.checkGroupExists(group[i], bowerJson, error);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "main-bower-files",
"version": "2.12.0",
"version": "2.13.0",
"description": "Get main files from your installed bower packages.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit e738462

Please sign in to comment.