From 4665321b37ee198785d9b234cab08bc200fd807c Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Tue, 8 May 2012 17:59:38 -0700 Subject: [PATCH] Project.getFilePaths does not traverse into ignored directories --- spec/app/project-spec.coffee | 9 +++++++++ src/app/project.coffee | 20 +++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/spec/app/project-spec.coffee b/spec/app/project-spec.coffee index 144b697e8..131f814f3 100644 --- a/spec/app/project-spec.coffee +++ b/spec/app/project-spec.coffee @@ -71,3 +71,12 @@ describe "Project", -> project.setPath(null) expect(project.getPath()?).toBeFalsy() expect(project.getRootDirectory()?).toBeFalsy() + + + describe ".getFilePaths()", -> + it "ignores files that return true from atom.ignorePath(path)", -> + spyOn(project, 'ignorePath').andCallFake (path) -> fs.base(path).match /a$/ + + project.getFilePaths().done (paths) -> + expect(paths).not.toContain('a') + expect(paths).toContain('b') diff --git a/src/app/project.coffee b/src/app/project.coffee index 0ada35dd4..673e3b704 100644 --- a/src/app/project.coffee +++ b/src/app/project.coffee @@ -1,6 +1,8 @@ fs = require 'fs' -Buffer = require 'buffer' _ = require 'underscore' +$ = require 'jquery' + +Buffer = require 'buffer' EventEmitter = require 'event-emitter' Directory = require 'directory' @@ -31,8 +33,20 @@ class Project @rootDirectory getFilePaths: -> - fs.async.listTree(@getPath()).pipe (paths) => - @relativize(path) for path in paths when fs.isFile(path) + deferred = $.Deferred() + + filePaths = [] + fs.traverseTree @getPath(), (path, prune) => + if @ignorePath(path) + prune() + else if fs.isFile(path) + filePaths.push @relativize(path) + + deferred.resolve filePaths + deferred + + ignorePath: (path) -> + fs.base(path).match(/\.DS_Store/) or path.match(/(^|\/)\.git(\/|$)/) open: (filePath) -> if filePath?