From 0ca5fa4e03916621afe8894c55524f3393ec0c60 Mon Sep 17 00:00:00 2001 From: Jeremias Volker Date: Mon, 23 Sep 2019 19:30:45 +0200 Subject: [PATCH 1/2] Adds option to pass functions to the `end_command` in extensions. Closes #43 --- src/controller.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/controller.js b/src/controller.js index 11737a3..d3706cf 100755 --- a/src/controller.js +++ b/src/controller.js @@ -307,7 +307,7 @@ fc.changeArtwork = function() { function swapArt() { debug('swapArt'); if (old_artwork) { - _endArt(old_format.end_command, old_artwork) + _endArt(old_format, old_artwork) .then(function() { _startArt(new_format, new_artwork).then(function() { fc.current_artwork = new_artwork; @@ -421,14 +421,23 @@ function _startArt(new_format, new_artwork) { /** * End a playing artwork. - * @param {string} _command + * @param {string} old_format * @param {object} old_artwork * @return {Promise} Resolves when command is complete. */ -function _endArt(_command, old_artwork) { +function _endArt(old_format, old_artwork) { debug('endArt'); - var tokens = old_artwork.tokens || {}, - command = _replaceTokens(_command, tokens); + var _command = old_format.end_command, + tokens = old_artwork.tokens || {}; + if (typeof _command === 'function') { + + // we're passing artwork-specific args and tokens here, letting the format + // construct the command dynamically... + var settings = old_artwork.settings || {}; + _command = _command.call(old_format, settings, tokens); + } + var command = _replaceTokens(_command, tokens); + return new Promise(function(resolve, reject) { proc_man.exec(command, function(err) { if (err) { From 68cf360d4afe39c64365e66c71179d28c19a3609 Mon Sep 17 00:00:00 2001 From: Jeremias Volker Date: Tue, 24 Sep 2019 13:13:23 +0200 Subject: [PATCH 2/2] Aligns artwork property name with database. Fixes #47 --- src/controller.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controller.js b/src/controller.js index d3706cf..5aab1f4 100755 --- a/src/controller.js +++ b/src/controller.js @@ -406,8 +406,8 @@ function _startArt(new_format, new_artwork) { // we're passing artwork-specific args and tokens here, letting the format // construct the command dynamically... - var settings = new_artwork.settings || {}; - _command = _command.call(new_format, settings, tokens); + var options = new_artwork.options || {}; + _command = _command.call(new_format, options, tokens); } var command = _replaceTokens(_command, tokens); @@ -433,8 +433,8 @@ function _endArt(old_format, old_artwork) { // we're passing artwork-specific args and tokens here, letting the format // construct the command dynamically... - var settings = old_artwork.settings || {}; - _command = _command.call(old_format, settings, tokens); + var options = old_artwork.options || {}; + _command = _command.call(old_format, options, tokens); } var command = _replaceTokens(_command, tokens);