From a4076dcfa50a49434121fc6fd6315f6902b08ec3 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 28 Jul 2015 17:34:45 -0700 Subject: [PATCH] Terminate the task after finishing --- src/default-directory-searcher.coffee | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/default-directory-searcher.coffee b/src/default-directory-searcher.coffee index a40fdbfe5..6fba05bcf 100644 --- a/src/default-directory-searcher.coffee +++ b/src/default-directory-searcher.coffee @@ -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,8 @@ class DefaultDirectorySearcher reject() return { then: promise.then.bind(promise) + catch: promise.catch.bind(promise) + directorySearch: directorySearch cancel: -> isCancelled = true directorySearch.cancel()