Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FIXUP) Make pdk build overwrite prompt consistent #427

Merged
merged 1 commit into from
Feb 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/pdk/cli/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ module PDK::CLI

unless opts[:force]
if builder.package_already_exists?
continue = PDK::CLI::Util.prompt_for_yes(
_("The file '%{package}' already exists. Overwrite?") % { package: builder.package_file },
default: false,
)
PDK.logger.info _("The file '%{package}' already exists.") % { package: builder.package_file }

unless continue
unless PDK::CLI::Util.prompt_for_yes(_('Overwrite?'), default: false)
PDK.logger.info _('Build cancelled; exiting.')
exit 0
end
Expand All @@ -55,6 +52,7 @@ module PDK::CLI
PDK.logger.info _('This module is not compatible with PDK, so PDK can not validate or test this build. ' \
'Unvalidated modules may have errors when uploading to the Forge. ' \
'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.')

unless PDK::CLI::Util.prompt_for_yes(_('Continue build without converting?'))
PDK.logger.info _('Build cancelled; exiting.')
exit 0
Expand Down
6 changes: 4 additions & 2 deletions spec/unit/pdk/cli/build_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
end

it 'continue to build' do
expect(PDK::CLI::Util).to receive(:prompt_for_yes).with(a_string_matching(%r{The file 'testuser-testmodule' already exists. Overwrite}i), default: false).and_return(true)
expect(logger).to receive(:info).with(a_string_matching(%r{The file 'testuser-testmodule' already exists}i))
expect(PDK::CLI::Util).to receive(:prompt_for_yes).with(a_string_matching(%r{Overwrite}i), default: false).and_return(true)
end
end

Expand All @@ -136,7 +137,8 @@
end

it 'cancel' do
expect(PDK::CLI::Util).to receive(:prompt_for_yes).with(a_string_matching(%r{The file 'testuser-testmodule' already exists. Overwrite}i), default: false).and_return(false)
expect(logger).to receive(:info).with(a_string_matching(%r{The file 'testuser-testmodule' already exists}i))
expect(PDK::CLI::Util).to receive(:prompt_for_yes).with(a_string_matching(%r{Overwrite}i), default: false).and_return(false)

expect { PDK::CLI.run(['build'] + command_opts) }.to exit_with_status(0)
end
Expand Down