Fix --output path with specified folder
This commit is contained in:
parent
52824f20b4
commit
b026be7cb3
|
@ -73,6 +73,8 @@ module Vagrant
|
|||
|
||||
self.class.validate!(env["package.output"], env["package.directory"])
|
||||
|
||||
package_with_folder_path if env["package.output"].include?(File::SEPARATOR)
|
||||
|
||||
raise Errors::PackageOutputDirectory if File.directory?(fullpath)
|
||||
|
||||
@app.call(env)
|
||||
|
@ -83,6 +85,16 @@ module Vagrant
|
|||
compress
|
||||
end
|
||||
|
||||
def package_with_folder_path
|
||||
folder_path = File.expand_path("..", @fullpath)
|
||||
create_box_folder(folder_path) unless File.directory?(folder_path)
|
||||
end
|
||||
|
||||
def create_box_folder(folder_path)
|
||||
@env[:ui].info(I18n.t("vagrant.actions.general.package.box_folder", folder_path: folder_path))
|
||||
FileUtils.mkdir_p(folder_path)
|
||||
end
|
||||
|
||||
def recover(env)
|
||||
@env = env
|
||||
|
||||
|
|
|
@ -2114,6 +2114,7 @@ en:
|
|||
package:
|
||||
packaging: "Packaging additional file: %{file}"
|
||||
compressing: "Compressing package to: %{fullpath}"
|
||||
box_folder: "Creating new folder: %{folder_path}"
|
||||
output_exists: |-
|
||||
The specified file '%{filename}' to save the package as already exists. Please
|
||||
remove this file or specify a different file name for outputting.
|
||||
|
|
|
@ -57,6 +57,18 @@ describe VagrantPlugins::CommandPackage::Command do
|
|||
expect{ package_command.execute }.to raise_error(Vagrant::Errors::MachineNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
context "with --output option" do
|
||||
|
||||
let(:argv){ ['--output', 'package-output-folder/default'] }
|
||||
|
||||
it "packages default machine inside specified folder" do
|
||||
expect(package_command).to receive(:package_vm).with(
|
||||
a_machine_named('default'), :output => "package-output-folder/default"
|
||||
)
|
||||
package_command.execute
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "with multiple arguments" do
|
||||
|
|
Loading…
Reference in New Issue