mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
Project.getFilePaths does not traverse into ignored directories
This commit is contained in:
parent
289193787e
commit
4665321b37
@ -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')
|
||||
|
@ -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?
|
||||
|
Loading…
Reference in New Issue
Block a user