Add versions to output

This commit is contained in:
Kevin Sawicki 2015-02-10 17:34:43 -08:00
parent e0654d62e8
commit c60e4345ed

View File

@ -8,15 +8,16 @@ module.exports = (grunt) ->
grunt.file.recurse nodeModulesDir, (absolutePath, rootPath, relativePath, fileName) ->
return if fileName isnt 'package.json'
{name} = grunt.file.readJSON(absolutePath)
modules[name] ?= 0
modules[name]++
{name, version} = grunt.file.readJSON(absolutePath)
modules[name] ?= {versions: {}, count: 0}
modules[name].count++
modules[name].versions[version] = true
sortedNames = Object.keys(modules).sort (name1, name2) ->
diff = modules[name2] - modules[name1]
diff = modules[name2].count - modules[name1].count
diff = name1.localeCompare(name2) if diff is 0
diff
sortedNames.forEach (name) ->
count = modules[name]
grunt.log.error "#{name}: #{count}" if count > 1
{count, versions} = modules[name]
grunt.log.error "#{name}: #{count} (#{Object.keys(versions).join(', ')})" if count > 1