From a585df6d2c09c7668d64ba89016443a9aadd3079 Mon Sep 17 00:00:00 2001 From: Garen Torikian Date: Wed, 27 Mar 2013 16:45:11 -0700 Subject: [PATCH] Use nak for fuzzyfinder, too --- .../fuzzy-finder/lib/fuzzy-finder-view.coffee | 2 +- .../fuzzy-finder/lib/load-paths-task.coffee | 36 ++++++++++--------- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee b/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee index 0748ac8d2..330e50fb3 100644 --- a/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee +++ b/src/packages/fuzzy-finder/lib/fuzzy-finder-view.coffee @@ -147,7 +147,7 @@ class FuzzyFinderView extends SelectList path.indexOf(options.filter) >= 0 else @projectPaths - console.log listedItems + @setArray(listedItems) options.done(listedItems) if options.done? else diff --git a/src/packages/fuzzy-finder/lib/load-paths-task.coffee b/src/packages/fuzzy-finder/lib/load-paths-task.coffee index 60a716688..12c80c327 100644 --- a/src/packages/fuzzy-finder/lib/load-paths-task.coffee +++ b/src/packages/fuzzy-finder/lib/load-paths-task.coffee @@ -1,5 +1,6 @@ _ = require 'underscore' -fs = require 'fs-utils' +BufferedProcess = require 'buffered-process' +$ = require 'jquery' module.exports = class LoadPathsTask @@ -13,21 +14,24 @@ class LoadPathsTask ignoredNames = ignoredNames.concat(config.get('core.ignoredNames') ? []) ignoreGitIgnoredFiles = config.get('core.hideGitIgnoredFiles') - paths = [] - isIgnored = (path) -> - for segment in path.split('/') - return true if _.contains(ignoredNames, segment) - ignoreGitIgnoredFiles and git?.isPathIgnored(fs.join(rootPath, path)) - onFile = (path) -> - return if @aborted - path = path.substring(rootPath.length + 1) - paths.push(path) unless isIgnored(path) - onDirectory = (path) => - not @aborted and not isIgnored(path.substring(rootPath.length + 1)) - onDone = => - @callback(paths) unless @aborted + command = require.resolve 'nak' + args = ['-l', rootPath] + args.unshift("--addVCSIgnores") if config.get('nak.addVCSIgnores') + args.unshift("-d", "#{ignoredNames.join(',')}") if ignoredNames.length > 0 - fs.traverseTree(rootPath, onFile, onDirectory, onDone) + paths = [] + deferred = $.Deferred() + exit = (code) => + if code is -1 + deferred.reject({command, code}) + else + @callback(paths) + deferred.resolve() + stdout = (data) -> + paths = paths.concat(data.split("\n")) + + new BufferedProcess({command, args, stdout, exit}) + deferred abort: -> - @aborted = true + @aborted = true \ No newline at end of file