Ignore missing symlinks in fsUtils.traverseTreeSync()

These were previously throwing an error from the call to
statSync().

Now statSync() is wrapped in a try block and only performed when
lstatSync() reports a symbolic link.
This commit is contained in:
Kevin Sawicki
2013-08-09 12:18:57 -07:00
parent 4f8f8c43a4
commit db649798ef
2 changed files with 14 additions and 2 deletions

View File

@@ -147,13 +147,16 @@ module.exports =
makeTree: (directoryPath) ->
mkdirp.sync(directoryPath) if directoryPath and not @exists(directoryPath)
traverseTreeSync: (rootPath, onFile, onDirectory) ->
traverseTreeSync: (rootPath, onFile, onDirectory=onFile) ->
return unless @isDirectorySync(rootPath)
traverse = (directoryPath, onFile, onDirectory) ->
for file in fs.readdirSync(directoryPath)
childPath = path.join(directoryPath, file)
stats = fs.statSync(childPath)
stats = fs.lstatSync(childPath)
if stats.isSymbolicLink()
try
stats = fs.statSync(childPath)
if stats.isDirectory()
traverse(childPath, onFile, onDirectory) if onDirectory(childPath)
else if stats.isFile()