mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Merge pull request #8126 from atom/bo-fix-process-leak
Fix process leak
This commit is contained in:
commit
f798fe2600
28
spec/default-directory-searcher-spec.coffee
Normal file
28
spec/default-directory-searcher-spec.coffee
Normal file
@ -0,0 +1,28 @@
|
||||
DefaultDirectorySearcher = require "../src/default-directory-searcher"
|
||||
Task = require "../src/task"
|
||||
path = require "path"
|
||||
|
||||
describe "DefaultDirectorySearcher", ->
|
||||
[searcher, dirPath] = []
|
||||
|
||||
beforeEach ->
|
||||
dirPath = path.resolve(__dirname, 'fixtures', 'dir')
|
||||
searcher = new DefaultDirectorySearcher
|
||||
|
||||
it "terminates the task after running a search", ->
|
||||
options =
|
||||
ignoreCase: false
|
||||
includeHidden: false
|
||||
excludeVcsIgnores: true
|
||||
inclusions: []
|
||||
globalExclusions: ['a-dir']
|
||||
didMatch: ->
|
||||
didError: ->
|
||||
didSearchPaths: ->
|
||||
searchPromise = searcher.search([{getPath: -> dirPath}], /abcdefg/, options)
|
||||
spyOn(Task::, 'terminate').andCallThrough()
|
||||
|
||||
waitsForPromise -> searchPromise
|
||||
|
||||
runs ->
|
||||
expect(Task::terminate).toHaveBeenCalled()
|
@ -18,7 +18,9 @@ class DirectorySearch
|
||||
@task.on 'scan:paths-searched', options.didSearchPaths
|
||||
@promise = new Promise (resolve, reject) =>
|
||||
@task.on('task:cancelled', reject)
|
||||
@task.start(rootPaths, regex.source, scanHandlerOptions, resolve)
|
||||
@task.start rootPaths, regex.source, scanHandlerOptions, =>
|
||||
@task.terminate()
|
||||
resolve()
|
||||
|
||||
# Public: Implementation of `then()` to satisfy the *thenable* contract.
|
||||
# This makes it possible to use a `DirectorySearch` with `Promise.all()`.
|
||||
@ -89,6 +91,7 @@ class DefaultDirectorySearcher
|
||||
reject()
|
||||
return {
|
||||
then: promise.then.bind(promise)
|
||||
catch: promise.catch.bind(promise)
|
||||
cancel: ->
|
||||
isCancelled = true
|
||||
directorySearch.cancel()
|
||||
|
Loading…
Reference in New Issue
Block a user