mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20: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',
|
doc: 'List nested/recursive indexes',
|
||||||
type: 'bool',
|
type: 'bool',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'-n': '-nested-only',
|
||||||
|
'-nested-only': {
|
||||||
|
doc: 'Ignore the top-level index and only list the indexes below',
|
||||||
|
type: 'bool',
|
||||||
|
},
|
||||||
|
|
||||||
})},
|
})},
|
||||||
function(path, options={}){
|
function(path, options={}){
|
||||||
|
var that = this
|
||||||
|
this.setupFeatures()
|
||||||
file.listIndexes(path)
|
file.listIndexes(path)
|
||||||
.on('end', function(paths){
|
.on('end', function(paths){
|
||||||
paths =
|
paths = paths
|
||||||
(options.recursive ?
|
.map(function(p){
|
||||||
paths
|
return p
|
||||||
: file.skipNested(paths))
|
.split(that.config['index-dir'])
|
||||||
.sortAs(paths)
|
.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){
|
for(var p of paths){
|
||||||
console.log(p.replace(/.ImageGrid$/, '')) } }) }],
|
console.log(p) } }) }],
|
||||||
|
|
||||||
/* XXX
|
/* XXX
|
||||||
startWorker: ['- System/Start as worker',
|
startWorker: ['- System/Start as worker',
|
||||||
|
|||||||
@ -43,30 +43,26 @@ var INDEX_DIR = '.ImageGrid'
|
|||||||
var skipNested =
|
var skipNested =
|
||||||
module.skipNested =
|
module.skipNested =
|
||||||
function(paths, index_dir, logger){
|
function(paths, index_dir, logger){
|
||||||
|
index_dir = index_dir || INDEX_DIR
|
||||||
logger = logger && logger.push('Skipping nested')
|
logger = logger && logger.push('Skipping nested')
|
||||||
|
|
||||||
paths = paths
|
paths = paths
|
||||||
.map(function(p){ return p.split(index_dir).shift() })
|
.map(function(p){
|
||||||
.sort(function(a, b){ return a.length - b.length })
|
return p.split(index_dir).shift() })
|
||||||
|
.sort(function(a, b){
|
||||||
|
return a.length - b.length })
|
||||||
for(var i=0; i < paths.length; i++){
|
for(var i=0; i < paths.length; i++){
|
||||||
var p = paths[i]
|
var p = paths[i]
|
||||||
|
if(p instanceof Array){
|
||||||
if(p == null){
|
continue }
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
for(var j=i+1; j < paths.length; j++){
|
for(var j=i+1; j < paths.length; j++){
|
||||||
|
if(paths[j] instanceof Array){
|
||||||
|
continue }
|
||||||
var o = paths[j].split(p)
|
var o = paths[j].split(p)
|
||||||
|
|
||||||
if(o[0] == '' && o.length > 1){
|
if(o[0] == '' && o.length > 1){
|
||||||
logger && logger.emit('skipping', paths[j])
|
logger && logger.emit('skipping', paths[j])
|
||||||
delete paths[j]
|
paths[j] = [] } } }
|
||||||
}
|
return paths.flat() }
|
||||||
}
|
|
||||||
}
|
|
||||||
return paths
|
|
||||||
.filter(function(p){ return !!p })
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Guarantee that the 'end' and 'match' handlers will always get called
|
// Guarantee that the 'end' and 'match' handlers will always get called
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user