mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-28 17:13:45 +03:00
Add grunt task to print duplicate modules
This commit is contained in:
parent
bc7198bab3
commit
cfde9954f2
22
build/tasks/output-module-counts.coffee
Normal file
22
build/tasks/output-module-counts.coffee
Normal file
@ -0,0 +1,22 @@
|
||||
path = require 'path'
|
||||
|
||||
module.exports = (grunt) ->
|
||||
grunt.registerTask 'output-module-counts', 'Log modules where more than one copy exists in node_modules', ->
|
||||
nodeModulesDir = path.resolve(__dirname, '..', '..', 'node_modules')
|
||||
|
||||
modules = {}
|
||||
grunt.file.recurse nodeModulesDir, (absolutePath, rootPath, relativePath, fileName) ->
|
||||
return if fileName isnt 'package.json'
|
||||
|
||||
{name} = grunt.file.readJSON(absolutePath)
|
||||
modules[name] ?= 0
|
||||
modules[name]++
|
||||
|
||||
sortedNames = Object.keys(modules).sort (name1, name2) ->
|
||||
diff = modules[name2] - modules[name1]
|
||||
diff = name1.localeCompare(name2) if diff is 0
|
||||
diff
|
||||
|
||||
sortedNames.forEach (name) ->
|
||||
count = modules[name]
|
||||
grunt.log.error "#{name}: #{count}" if count > 1
|
Loading…
Reference in New Issue
Block a user