Skip to content

Commit

Permalink
audit: move logic into command/audit.js
Browse files Browse the repository at this point in the history
  • Loading branch information
othiym23 committed Nov 29, 2015
1 parent e0359a0 commit 23cb54b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import options from './config/options.js'

import albums from './command/albums.js'
import artists from './command/artists.js'
import audit from './metadata/audit.js'
import audit from './command/audit.js'
import makePlaylist from './utils/make-playlist.js'
import optimize from './command/optimize.js'
import saveConfig from './config/save.js'
Expand Down Expand Up @@ -84,27 +84,10 @@ switch (yargs.argv._[0]) {
return 'must pass either 1 or more files containing metadata'
})
.argv

const files = argv._.slice(1)
roots = argv._.slice(1).map(r => untildify(r))
log.silly('audit', 'argv', argv)
log.silly('audit', 'files', files)

log.enableProgress()
command = scanAlbums(files, groups)
.then(albums => {
log.disableProgress()
log.silly('audit', 'albums', albums)
for (let album of albums) {
const id = album.artist.name + ': ' + album.name + ' /'
for (let warning of audit(album)) log.warn('audit', id, warning)
}
log.silly('audit', 'tracker debugging', log.tracker.debug())
})
.catch(e => {
log.disableProgress()
log.error('audit', e.stack)
})

command = audit(roots, groups)
break
case 'inspect':
argv = yargs.reset()
Expand Down
20 changes: 20 additions & 0 deletions src/command/audit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import log from 'npmlog'

import auditAlbum from '../metadata/audit.js'
import scanAlbums from '../albums.js'

export default function audit (roots, groups) {
log.silly('audit', 'files', roots)

log.enableProgress()
return scanAlbums(roots, groups)
.then(albums => {
log.disableProgress()
log.silly('audit', 'albums', albums)
for (let album of albums) {
const id = album.artist.name + ': ' + album.name + ' /'
for (let warning of auditAlbum(album)) log.warn('audit', id, warning)
}
log.silly('audit', 'tracker debugging', log.tracker.debug())
})
}

0 comments on commit 23cb54b

Please sign in to comment.