Fix working directory for default plugin configurations
Change-Id: Ie4bafe50692350e78892fe7c65c778c7d9c549e6
diff --git a/Changes b/Changes
index 2fcb711..c781987 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.41 2021-02-22
+0.41 2021-02-27
- Introduce CORS headers to the proxy.
- Introduce Content Security Policy.
- Remove default api endpoint from config to
@@ -30,6 +30,7 @@
kalamar->request helper.
- Move /js/tracking.js to /settings/asset/tracking.js
to simplify asset configuration in proxy servers.
+ - Fix working directory for plugin configuration.
0.40 2020-12-17
- Modernize ES and fix in-loops.
diff --git a/lib/Kalamar/Plugin/Plugins.pm b/lib/Kalamar/Plugin/Plugins.pm
index 73dcdbe..e2eadbf 100644
--- a/lib/Kalamar/Plugin/Plugins.pm
+++ b/lib/Kalamar/Plugin/Plugins.pm
@@ -1,6 +1,7 @@
package Kalamar::Plugin::Plugins;
use Mojo::Base 'Mojolicious::Plugin';
-use Mojo::JSON qw'decode_json';
+use Mojo::JSON 'decode_json';
+use Mojo::File 'path';
# Register the plugin
sub register {
@@ -15,7 +16,11 @@
if ($param->{default_plugins}) {
# Read default plugins file
- my $default = Mojo::File->new($param->{default_plugins});
+ my $default = path($param->{default_plugins});
+
+ # Use correct working directory
+ $default = $app->home->child($default) unless $default->is_abs;
+
my $json_array = decode_json $default->slurp;
# If any scripts are defined