diff --git a/src/hash.ts b/src/hash.ts index 998bd63..3b7113d 100644 --- a/src/hash.ts +++ b/src/hash.ts @@ -9,7 +9,7 @@ import { log } from './utils'; * @param {*} file The file to hash * @returns The SHA1 hash */ -module.exports = (file: FileData) => +export default (file: FileData) => new Promise((resolve, reject) => toArray((fs.createReadStream(file.path))) .then((parts: any[]) => Buffer.concat(parts.map((part: any) => (Buffer.isBuffer(part) ? part : Buffer.from(part))))) diff --git a/src/thumbnails.ts b/src/thumbnails.ts index 0253a78..586c542 100644 --- a/src/thumbnails.ts +++ b/src/thumbnails.ts @@ -81,7 +81,7 @@ function getImageThumbnail(file: FileData) { * @param {*} file The file to generate a thumbnail for * @returns The thumbnail filename (NOT the path) */ -module.exports = (file: FileData) => +export default (file: FileData) => new Promise((resolve, reject) => (file.is.video ? getVideoThumbnail : file.is.image ? getImageThumbnail : () => Promise.resolve())(file) .then(() => resolve((file.is.video || file.is.image) ? getNewName(file.randomId) : file.is.audio ? 'views/ass-audio-icon.png' : 'views/ass-file-icon.png')) diff --git a/src/vibrant.ts b/src/vibrant.ts index 38f539d..6a75454 100644 --- a/src/vibrant.ts +++ b/src/vibrant.ts @@ -18,7 +18,7 @@ function getVibrant(file: FileData, resolve: Function, reject: Function) { .quality(QUALITY) .getPalette() .then((palettes) => resolve(palettes[Object.keys(palettes).sort((a, b) => palettes[b]!.population - palettes[a]!.population)[0]]!.hex)) - .catch(() => reject); + .catch((err) => reject(err)); } /** @@ -26,4 +26,4 @@ function getVibrant(file: FileData, resolve: Function, reject: Function) { * @param {*} file The file to get a colour from * @returns The Vibrant colour as a Hex value (or random Hex value for videos) */ -module.exports = (file: FileData) => new Promise((resolve, reject) => !file.is.image ? resolve(randomHexColour()) : getVibrant(file, resolve, reject)); // skipcq: JS-0229 +export default (file: FileData) => new Promise((resolve, reject) => !file.is.image ? resolve(randomHexColour()) : getVibrant(file, resolve, reject)); // skipcq: JS-0229