Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -69,7 +68,6 @@ var searchMethods = {
* @return function
*/
function searchMethod(method, options) {

if(!searchMethods.hasOwnProperty(method)) {
throw new TypeError('Method '+method+' is not available')
}
Expand Down
9 changes: 7 additions & 2 deletions lib/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Owner

@soyuka soyuka Jan 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is bothering me and should not be needed.

Take a look at the paths function here.

Your custom search is leading to the path not being an array nor a string there. However, the data returned by the custom searched should be parsed here.
It the output is how you said:

somepath
somepath2

The search will output an array and this should not be needed.

var v = p.join(path, f)
// debug('Map stat', f)

Expand Down