Skip to content

Commit

Permalink
Merge pull request #427 from scotje/build_overwrite_prompt
Browse files Browse the repository at this point in the history
(FIXUP) Make `pdk build` overwrite prompt consistent
  • Loading branch information
bmjen authored Feb 14, 2018
2 parents 05ae699 + d86716f commit c6db211
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit c6db211

Please sign in to comment.