-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9052 from CartoDB/grunt_prefligh
added checks to run grunt
- Loading branch information
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
function alldeps (mod, deps, name, parentVersion) { | ||
name = name || mod.name; | ||
return Object.keys(mod.dependencies).reduce(function (all, dependency) { | ||
if (!all.hasOwnProperty(dependency)) { | ||
all[dependency] = {}; | ||
} | ||
|
||
var version = mod.dependencies[dependency].version; | ||
var resolved = mod.dependencies[dependency].resolved; | ||
if (!all[dependency].hasOwnProperty(version)) { | ||
all[dependency][resolved] = {}; | ||
} | ||
|
||
all[dependency][resolved][name] = parentVersion || version; | ||
if (mod.dependencies[dependency].dependencies) { | ||
alldeps(mod.dependencies[dependency], all, dependency, version); | ||
} | ||
return all; | ||
}, deps || {}); | ||
} | ||
|
||
/** | ||
* Checks all modules dependencies versions within a npm-shrinkwrap to not be | ||
* duplicated from different parent dependencies. | ||
* | ||
* For instance if there are a couple of dependencies using a different version | ||
* of backbone it will return backbone with its parent dependencies. | ||
*/ | ||
function duplicated (shrinkwrap, modulesToValidate) { | ||
shrinkwrap = shrinkwrap || require('./npm-shrinkwrap.json'); | ||
var all = alldeps(shrinkwrap); | ||
|
||
modulesToValidate = modulesToValidate || Object.keys(all); | ||
|
||
return modulesToValidate.reduce(function (duplicatedMods, mod) { | ||
var modVersions = Object.keys(all[mod]); | ||
if (modVersions.length > 1) { | ||
var invalidMod = { name: mod, versions: [] }; | ||
|
||
modVersions.forEach(function (modVersion) { | ||
invalidMod.versions.push({version: modVersion, from: all[mod][modVersion]}); | ||
}); | ||
duplicatedMods.push(invalidMod); | ||
} | ||
return duplicatedMods; | ||
}, []); | ||
} | ||
|
||
module.exports = duplicated; |