mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user