mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
more work on ig ls...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
04936a20e7
commit
6b4dfe0320
@ -326,17 +326,36 @@ var CLIActions = actions.Actions({
|
||||
doc: 'List nested/recursive indexes',
|
||||
type: 'bool',
|
||||
},
|
||||
|
||||
'-n': '-nested-only',
|
||||
'-nested-only': {
|
||||
doc: 'Ignore the top-level index and only list the indexes below',
|
||||
type: 'bool',
|
||||
},
|
||||
|
||||
})},
|
||||
function(path, options={}){
|
||||
var that = this
|
||||
this.setupFeatures()
|
||||
file.listIndexes(path)
|
||||
.on('end', function(paths){
|
||||
paths =
|
||||
(options.recursive ?
|
||||
paths
|
||||
: file.skipNested(paths))
|
||||
.sortAs(paths)
|
||||
paths = paths
|
||||
.map(function(p){
|
||||
return p
|
||||
.split(that.config['index-dir'])
|
||||
.shift() })
|
||||
// normalize path...
|
||||
path.at(-1) != '/'
|
||||
&& (path += '/')
|
||||
// handle --nested-only
|
||||
options['nested-only']
|
||||
&& paths.splice(paths.indexOf(path), 1)
|
||||
paths = options.recursive ?
|
||||
paths
|
||||
: file.skipNested(paths)
|
||||
.sortAs(paths)
|
||||
for(var p of paths){
|
||||
console.log(p.replace(/.ImageGrid$/, '')) } }) }],
|
||||
console.log(p) } }) }],
|
||||
|
||||
/* XXX
|
||||
startWorker: ['- System/Start as worker',
|
||||
|
||||
@ -43,30 +43,26 @@ var INDEX_DIR = '.ImageGrid'
|
||||
var skipNested =
|
||||
module.skipNested =
|
||||
function(paths, index_dir, logger){
|
||||
index_dir = index_dir || INDEX_DIR
|
||||
logger = logger && logger.push('Skipping nested')
|
||||
|
||||
paths = paths
|
||||
.map(function(p){ return p.split(index_dir).shift() })
|
||||
.sort(function(a, b){ return a.length - b.length })
|
||||
.map(function(p){
|
||||
return p.split(index_dir).shift() })
|
||||
.sort(function(a, b){
|
||||
return a.length - b.length })
|
||||
for(var i=0; i < paths.length; i++){
|
||||
var p = paths[i]
|
||||
|
||||
if(p == null){
|
||||
continue
|
||||
}
|
||||
|
||||
if(p instanceof Array){
|
||||
continue }
|
||||
for(var j=i+1; j < paths.length; j++){
|
||||
if(paths[j] instanceof Array){
|
||||
continue }
|
||||
var o = paths[j].split(p)
|
||||
|
||||
if(o[0] == '' && o.length > 1){
|
||||
logger && logger.emit('skipping', paths[j])
|
||||
delete paths[j]
|
||||
}
|
||||
}
|
||||
}
|
||||
return paths
|
||||
.filter(function(p){ return !!p })
|
||||
}
|
||||
paths[j] = [] } } }
|
||||
return paths.flat() }
|
||||
|
||||
|
||||
// Guarantee that the 'end' and 'match' handlers will always get called
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user