From 1420ca9adb5105b8db9413829efbf34ff3525521 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 3 Jan 2012 17:22:03 -0700 Subject: [PATCH] Rename Project.list -> Project.getFilePaths, and change its behavior. getFilePaths only resolves to the project-relative paths of all files in the project, excluding directories. --- spec/atom/project-spec.coffee | 12 +++++++----- src/atom/project.coffee | 6 ++++-- src/atom/root-view.coffee | 7 ++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/spec/atom/project-spec.coffee b/spec/atom/project-spec.coffee index 459ca34b0..8c5665ef2 100644 --- a/spec/atom/project-spec.coffee +++ b/spec/atom/project-spec.coffee @@ -6,10 +6,12 @@ describe "Project", -> beforeEach -> project = new Project(require.resolve('fixtures/dir')) - describe ".list()", -> + describe ".getFilePaths()", -> it "returns a promise which resolves to a list of all file urls in the project, recursively", -> - waitsFor (complete) -> - project.list().done (result) -> - expect(result).toEqual(fs.list(project.url, true)) - complete() + expectedPaths = for url in fs.list(project.url, true) when fs.isFile url + url.replace project.url, '' + + waitsForPromise -> + project.getFilePaths().done (result) -> + expect(result).toEqual(expectedPaths) diff --git a/src/atom/project.coffee b/src/atom/project.coffee index 0e266f28b..6b4576baa 100644 --- a/src/atom/project.coffee +++ b/src/atom/project.coffee @@ -5,6 +5,8 @@ module.exports = class Project constructor: (@url) -> - list: -> - fs.async.list(@url, true) + getFilePaths: -> + projectUrl = @url + fs.async.list(@url, true).pipe (urls) -> + url.replace(projectUrl, "") for url in urls when fs.isFile(url) diff --git a/src/atom/root-view.coffee b/src/atom/root-view.coffee index 14cb7add1..04c126da1 100644 --- a/src/atom/root-view.coffee +++ b/src/atom/root-view.coffee @@ -30,16 +30,13 @@ class RootView extends Template @main.after(pane) toggleFileFinder: -> - return unless @editor.buffer.url + return unless @project if @fileFinder @fileFinder.remove() @fileFinder = null else - directory = fs.directory @editor.buffer.url - return fs.async.list(directory, true).done (urls) => - urls = (url for url in urls when fs.isFile url) - urls = (url.replace(directory, "") for url in urls) + @project.getFilePaths().done (urls) => @fileFinder = FileFinder.build({urls}) @addPane(@fileFinder) @fileFinder.input.focus()