diff --git a/README.md b/README.md index c84d89b..b2ba71e 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ fastlane add_plugin file_manager ## About fastlane-plugin-file_manager -Copy and remove files. +Copy, move and remove files. ## Example @@ -23,6 +23,7 @@ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plu ```ruby lane :test do copy_files(source: "test.rb", destination: "lib") + move_files(source: "test.rb", destination: "lib") remove_files(path: "test.rb") end ``` diff --git a/fastlane/Fastfile b/fastlane/Fastfile index aa5f756..353270c 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -1,4 +1,5 @@ lane :test do copy_files(source: "test.rb", destination: "lib") + move_files(source: "test.rb", destination: "lib") remove_files(path: "test.rb") end diff --git a/lib/fastlane/plugin/file_manager/actions/move_files_action.rb b/lib/fastlane/plugin/file_manager/actions/move_files_action.rb new file mode 100644 index 0000000..1149c3f --- /dev/null +++ b/lib/fastlane/plugin/file_manager/actions/move_files_action.rb @@ -0,0 +1,38 @@ +require "fastlane/action" + +module Fastlane + module Actions + class MoveFilesAction < Action + def self.run(params) + Actions.sh("mv", params[:source], params[:destination]) + end + + def self.description + "Move files" + end + + def self.authors + ["Andrey Novikov"] + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :source, + short_option: "-s", + description: "Source", + optional: false, + type: String), + FastlaneCore::ConfigItem.new(key: :destination, + short_option: "-d", + description: "Destination", + optional: false, + type: String) + ] + end + + def self.is_supported?(platform) + true + end + end + end +end diff --git a/spec/move_files_action_spec.rb b/spec/move_files_action_spec.rb new file mode 100644 index 0000000..da5360b --- /dev/null +++ b/spec/move_files_action_spec.rb @@ -0,0 +1,9 @@ +describe Fastlane::Actions::MoveFilesAction do + describe "#run" do + it "executes mv command with source and destination" do + expect(Fastlane::Actions).to receive(:sh).with("mv", "test.rb", "lib") + + Fastlane::Actions::MoveFilesAction.run(source: "test.rb", destination: "lib") + end + end +end