From 4ddc44af232811c4d907c0f1885a84605243b517 Mon Sep 17 00:00:00 2001 From: Bennett Kanuka Date: Fri, 19 Jan 2018 20:07:10 -0500 Subject: [PATCH] quick fix for external search --- lib/search/index.js | 6 ++---- lib/tree.js | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/search/index.js b/lib/search/index.js index 30136999..93ed7a6e 100644 --- a/lib/search/index.js +++ b/lib/search/index.js @@ -52,11 +52,10 @@ var searchMethods = { .catch(nodata) }, custom: function(options) { - if(!options || !options.search || !options.search.command) { + if(!options || !options.command) { return this.find(options) } - - return (search, path) => spawner.spawn(options.search.command.replace('${search}', search), {cwd: path}) + return (search, path) => spawner.spawn(options.command.replace('${search}', search).replace('${path}', path), {cwd: path}) .catch(nodata) }, native: nativeSearch @@ -69,7 +68,6 @@ var searchMethods = { * @return function */ function searchMethod(method, options) { - if(!searchMethods.hasOwnProperty(method)) { throw new TypeError('Method '+method+' is not available') } diff --git a/lib/tree.js b/lib/tree.js index b0d36356..0acff5e6 100644 --- a/lib/tree.js +++ b/lib/tree.js @@ -261,8 +261,13 @@ var tree = function(path, options) { var totalSize = 0 var directorySize = getDirectorySize(options) - return paths(path, options) - .map(function(f) { + var pathsArray = paths(path, options) + + if(Array.isArray(path)) { + path = '' + } + + return pathsArray.map(function(f) { var v = p.join(path, f) // debug('Map stat', f)