From 12c9b3746af6131cee506b8e657c6d8cd2f466c8 Mon Sep 17 00:00:00 2001 From: rprieto Date: Sun, 20 Apr 2014 00:32:01 +1000 Subject: [PATCH] Cleanup --- src/index.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index c05185b..a4ed9a4 100644 --- a/src/index.js +++ b/src/index.js @@ -29,7 +29,7 @@ function photos(opts) { var fns = files.map(function(file) { return function(next) { thumbs.photo({ - input: path.resolve(path.join(opts.input, file)), + input: path.join(opts.input, file), thumbnail: path.join(thumbsFolder, file), size: opts.size }, next); @@ -45,9 +45,9 @@ function videos(opts) { var fns = files.map(function(file) { return function(next) { thumbs.video({ - input: path.resolve(path.join(opts.input, file)), - thumbnail: path.join(thumbsFolder, file.replace(/\.[a-z0-9]+$/, '.jpg')), - poster: path.join(thumbsFolder, file.replace(/\.[a-z0-9]+$/, '_poster.jpg')), + input: path.join(opts.input, file), + thumbnail: path.join(thumbsFolder, ext(file, '.jpg')), + poster: path.join(thumbsFolder, ext(file, '_poster.jpg')), size: opts.size }, next); }; @@ -78,6 +78,10 @@ function support(opts) { fs.copy(pub, out, log('Supporting files')); } +function ext(file, newExtension) { + return file.replace(/\.[a-z0-9]+$/, newExtension); +} + function log(message) { return function(err) { var tag = pad(message + ': ', 25);