pi-rfid-jukebox/jukebox/library/file-backend.js
Annika Backstrom beacdf98e7 Add in missing return statements
Fixes several bugs relating to dupe callbacks on the same tag
2017-04-09 22:40:23 -04:00

26 lines
455 B
JavaScript

"use strict";
const glob = require('glob');
const basename = require('path').basename;
class FileBackend {
constructor(config) {
this.config = config;
}
find(tag, callback) {
glob('media/' + tag + ' - *.mp3', (err, files) => {
if (files.length > 0) {
return callback(basename(files[0]));
}
callback();
});
}
}
module.exports = function(config) {
return new FileBackend(config);
};
// vim:ts=2 sw=2 et: