Merge pull request #959 from atom/ks-q-continuum

Switch to q from $.Deferred
This commit is contained in:
Kevin Sawicki 2013-10-14 10:00:38 -07:00
commit 002e3898fa
3 changed files with 5 additions and 89 deletions

View File

@ -51,12 +51,12 @@
"autoflow": "0.3.0",
"bookmarks": "0.5.0",
"bracket-matcher": "0.6.0",
"collaboration": "0.21.0",
"collaboration": "0.23.0",
"command-logger": "0.4.0",
"command-palette": "0.4.0",
"editor-stats": "0.3.0",
"exception-reporting": "0.4.0",
"find-and-replace": "0.24.2",
"find-and-replace": "0.25.0",
"fuzzy-finder": "0.10.0",
"gfm": "0.5.0",
"git-diff": "0.6.1",
@ -74,7 +74,7 @@
"snippets": "0.6.0",
"spell-check": "0.6.0",
"status-bar": "0.10.1",
"symbols-view": "0.8.0",
"symbols-view": "0.10.0",
"tabs": "0.5.0",
"terminal": "0.10.0",
"timecop": "0.5.0",

View File

@ -280,76 +280,6 @@ describe "Project", ->
expect(project.getPath()?).toBeFalsy()
expect(project.getRootDirectory()?).toBeFalsy()
describe ".getFilePaths()", ->
it "returns file paths using a promise", ->
paths = null
waitsForPromise ->
project.getFilePaths().done (foundPaths) -> paths = foundPaths
runs ->
expect(paths.length).toBeGreaterThan 0
it "ignores files that return true from atom.ignorePath(path)", ->
spyOn(project, 'isPathIgnored').andCallFake (filePath) -> path.basename(filePath).match /a$/
paths = null
waitsForPromise ->
project.getFilePaths().done (foundPaths) -> paths = foundPaths
runs ->
expect(paths).not.toContain(project.resolve('a'))
expect(paths).toContain(project.resolve('b'))
describe "when config.core.hideGitIgnoredFiles is true", ->
it "ignores files that are present in .gitignore if the project is a git repo", ->
config.set "core.hideGitIgnoredFiles", true
project.setPath(path.join(__dirname, 'fixtures', 'git', 'working-dir'))
paths = null
waitsForPromise ->
project.getFilePaths().done (foundPaths) -> paths = foundPaths
runs ->
expect(paths).not.toContain('ignored.txt')
describe "ignored file name", ->
ignoredFile = null
beforeEach ->
ignoredFile = path.join(__dirname, 'fixtures', 'dir', 'ignored.txt')
fs.writeSync(ignoredFile, "")
afterEach ->
fs.remove(ignoredFile)
it "ignores ignored.txt file", ->
paths = null
config.pushAtKeyPath("core.ignoredNames", "ignored.txt")
waitsForPromise ->
project.getFilePaths().done (foundPaths) -> paths = foundPaths
runs ->
expect(paths).not.toContain('ignored.txt')
describe "ignored folder name", ->
ignoredFile = null
beforeEach ->
ignoredFile = path.join(__dirname, 'fixtures', 'dir', 'ignored', 'ignored.txt')
fs.writeSync(ignoredFile, "")
afterEach ->
fs.remove(ignoredFile)
it "ignores ignored folder", ->
paths = null
config.get("core.ignoredNames").push("ignored.txt")
config.set("core.ignoredNames", config.get("core.ignoredNames"))
waitsForPromise ->
project.getFilePaths().done (foundPaths) -> paths = foundPaths
runs ->
expect(paths).not.toContain('ignored/ignored.txt')
describe ".scan(options, callback)", ->
describe "when called with a regex", ->
it "calls the callback with all regex results in all files in the project", ->

View File

@ -4,7 +4,6 @@ url = require 'url'
Q = require 'q'
_ = require './underscore-extensions'
$ = require './jquery-extensions'
telepath = require 'telepath'
{Range} = telepath
TextBuffer = require './text-buffer'
@ -132,19 +131,6 @@ class Project
getRootDirectory: ->
@rootDirectory
# Public: Fetches the name of every file (that's not `git ignore`d) in the
# project.
#
# Returns an {Array} of {String}s.
getFilePaths: ->
deferred = $.Deferred()
paths = []
onFile = (path) => paths.push(path) unless @isPathIgnored(path)
onDirectory = -> true
fsUtils.traverseTreeSync(@getPath(), onFile, onDirectory)
deferred.resolve(paths)
deferred.promise()
# Public: Determines if a path is ignored via Atom configuration.
isPathIgnored: (path) ->
for segment in path.split("/")
@ -316,7 +302,7 @@ class Project
iterator = options
options = {}
deferred = $.Deferred()
deferred = Q.defer()
searchOptions =
ignoreCase: regex.ignoreCase
@ -335,7 +321,7 @@ class Project
task.on 'scan:paths-searched', (numberOfPathsSearched) ->
options.onPathsSearched(numberOfPathsSearched)
deferred
deferred.promise
# Private:
buildEditSessionForBuffer: (buffer, editSessionOptions) ->