Skip to content

Commit

Permalink
Fix env variables is not loaded when REXER_COMMAND_PREFIX is set
Browse files Browse the repository at this point in the history
  • Loading branch information
hidakatsuya committed Sep 3, 2024
1 parent 7e07d65 commit 190ff03
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/rexer/extension/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ def run_db_migrate(extra_envs = {})
return unless needs_db_migration?

envs = {"NAME" => name.to_s}.merge(extra_envs)
cmds = cmd("bundle", "exec", "rake", Rexer.verbosity.debug? ? nil : "-q", "redmine:plugins:migrate")
cmds = build_cmd("bundle", "exec", "rake", Rexer.verbosity.debug? ? nil : "-q", "redmine:plugins:migrate", envs:)

broadcast(:processing, "Execute #{cmds} with #{envs}")
broadcast(:processing, "Execute #{cmds}")

if Rexer.verbosity.debug?
system(envs, cmds, exception: true)
system(cmds, exception: true)
else
_, error, status = Open3.capture3(envs, cmds)
_, error, status = Open3.capture3(cmds)
raise error unless status.success?
end
end
Expand All @@ -55,8 +55,9 @@ def source
@source ||= Source.from_definition(definition.source)
end

def cmd(*command)
[Rexer.config.command_prefix, *command].compact.join(" ")
def build_cmd(*command, envs: {})
envs_str = envs.map { [_1, _2].join("=") }
[Rexer.config.command_prefix, *command, *envs_str].compact.join(" ")
end
end

Expand Down Expand Up @@ -86,7 +87,7 @@ def load_from_source
def run_bundle_install
return unless plugin_dir.join("Gemfile").exist?

cmds = cmd("bundle", "install", Rexer.verbosity.debug? ? nil : "--quiet")
cmds = build_cmd("bundle", "install", Rexer.verbosity.debug? ? nil : "--quiet")

broadcast(:processing, "Execute #{cmds}")

Expand Down

0 comments on commit 190ff03

Please sign in to comment.