Implement `file_replace_content' task action
This commit is contained in:
27
lib/producer/core/actions/file_replace_content.rb
Normal file
27
lib/producer/core/actions/file_replace_content.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
module Producer
|
||||
module Core
|
||||
module Actions
|
||||
class FileReplaceContent < Action
|
||||
def apply
|
||||
fs.file_write path, replaced_content
|
||||
end
|
||||
|
||||
def path
|
||||
arguments[0]
|
||||
end
|
||||
|
||||
def pattern
|
||||
arguments[1]
|
||||
end
|
||||
|
||||
def replacement
|
||||
arguments[2]
|
||||
end
|
||||
|
||||
def replaced_content
|
||||
fs.file_read(path).gsub pattern, replacement
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -13,8 +13,9 @@ module Producer
|
||||
define_action :echo, Actions::Echo
|
||||
define_action :sh, Actions::ShellCommand
|
||||
|
||||
define_action :mkdir, Actions::Mkdir
|
||||
define_action :file_write, Actions::FileWriter
|
||||
define_action :mkdir, Actions::Mkdir
|
||||
define_action :file_write, Actions::FileWriter
|
||||
define_action :file_replace_content, Actions::FileReplaceContent
|
||||
|
||||
attr_reader :env, :block, :actions
|
||||
|
||||
|
Reference in New Issue
Block a user