lib/hanami/model/migrator/adapter.rb in hanami-model-1.0.1 vs lib/hanami/model/migrator/adapter.rb in hanami-model-1.0.2
- old
+ new
@@ -1,7 +1,8 @@
require 'uri'
require 'shellwords'
+require 'open3'
module Hanami
module Model
class Migrator
# Migrator base adapter
@@ -173,9 +174,18 @@
# @since 0.4.0
# @api private
def escape(string)
Shellwords.escape(string) unless string.nil?
+ end
+
+ # @since 1.0.2
+ # @api private
+ def execute(command, env: {}, error: ->(err) { raise MigrationError.new(err) })
+ Open3.popen3(env, command) do |_, stdout, stderr, wait_thr|
+ error.call(stderr.read) unless wait_thr.value.success?
+ yield stdout if block_given?
+ end
end
end
end
end
end