diff --git a/CHANGELOG.md b/CHANGELOG.md index 90cf32a..3671958 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Add fall back in case of the primary server is not defined. ([@chubchenko][]) +- Require `json` to convert `Hash` object to `JSON`. ([@chubchenko][]) ## [0.1.4] - 2021-07-27 ### Fixed diff --git a/lib/capistrano/slacky/on.rb b/lib/capistrano/slacky/on.rb index a0f42b5..eee5937 100644 --- a/lib/capistrano/slacky/on.rb +++ b/lib/capistrano/slacky/on.rb @@ -18,7 +18,9 @@ class Path module_function def on(within:, &block) - ::Capistrano::DSL.on(::Capistrano::Configuration.env.primary(:app)) do + role = ::Capistrano::Configuration.env.primary(:app) || ::Capistrano::Configuration.env.roles(:all).first + + ::Capistrano::DSL.on(role) do ::SSHKit::Backend.current.within(PATH_MAP.fetch(within).call, &block) end end diff --git a/lib/capistrano/slacky/payload.rb b/lib/capistrano/slacky/payload.rb index 7be28eb..e461d6d 100644 --- a/lib/capistrano/slacky/payload.rb +++ b/lib/capistrano/slacky/payload.rb @@ -5,6 +5,8 @@ module Capistrano module Slacky class Payload + require "json" + def initialize(env:, action:) @env = env @action = action