mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Handle broken symlinks when walking
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
|
||||
module.exports = (grunt) ->
|
||||
@@ -19,7 +20,7 @@ module.exports = (grunt) ->
|
||||
getOtherTotal = ->
|
||||
Object.keys(otherModules).length
|
||||
|
||||
grunt.file.recurse nodeModulesDir, (absolutePath, rootPath, relativePath, fileName) ->
|
||||
recurseHandler = (absolutePath, rootPath, relativePath, fileName) ->
|
||||
return if fileName isnt 'package.json'
|
||||
|
||||
{name, version, repository} = grunt.file.readJSON(absolutePath)
|
||||
@@ -36,6 +37,22 @@ module.exports = (grunt) ->
|
||||
modules[name].count++
|
||||
modules[name].versions[version] = true
|
||||
|
||||
walkNodeModuleDir = ->
|
||||
grunt.file.recurse(nodeModulesDir, recurseHandler)
|
||||
|
||||
# Handle broken symlinks that grunt.file.recurse fails to handle
|
||||
loop
|
||||
try
|
||||
walkNodeModuleDir()
|
||||
break
|
||||
catch error
|
||||
if error.code is 'ENOENT'
|
||||
fs.unlinkSync(error.path)
|
||||
otherModules = {}
|
||||
atomModules = {}
|
||||
else
|
||||
break
|
||||
|
||||
if getAtomTotal() > 0
|
||||
console.log "Atom Modules: #{getAtomTotal()}"
|
||||
sortModuleNames(atomModules).forEach (name) ->
|
||||
|
||||
Reference in New Issue
Block a user