Skip to content

Commit

Permalink
Merge pull request #506 from rodjek/pdk-809
Browse files Browse the repository at this point in the history
(PDK-809) Exit early if the module is not PDK compatible
  • Loading branch information
bmjen committed May 16, 2018
2 parents 2bc3a1b + 6fecd34 commit 1c719d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/pdk/cli/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def module_version_check

# This means the module does not have a pdk-version tag in the metadata.json
# and will require a pdk convert.
if module_pdk_ver.nil?
PDK.logger.warn _('This module is not PDK compatible. Run `pdk convert` to make it compatible with your version of PDK.')
raise PDK::CLI::ExitWithError, _('This module is not PDK compatible. Run `pdk convert` to make it compatible with your version of PDK.') if module_pdk_ver.nil?

# This checks that the version of pdk in the module's metadata is older
# than 1.3.1, which means the module will need to run pdk convert to the
# new templates.
elsif Gem::Version.new(module_pdk_ver) < Gem::Version.new('1.3.1')
if Gem::Version.new(module_pdk_ver) < Gem::Version.new('1.3.1')
PDK.logger.warn _('This module template is out of date. Run `pdk convert` to make it compatible with your version of PDK.')
# This checks if the version of the installed PDK is older than the
# version in the module's metadata, and advises the user to upgrade to
Expand Down
8 changes: 3 additions & 5 deletions spec/unit/pdk/cli/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@
context 'if module doesn\'t have pdk-version in metadata' do
let(:module_pdk_ver) { nil }

before(:each) do
expect(logger).to receive(:warn).with(a_string_matching(%r{This module is not PDK compatible. Run `pdk convert` to make it compatible with your version of PDK.}i))
end

it 'does not raise an error' do
expect { module_version_check }.not_to raise_error
expect {
module_version_check
}.to raise_error(PDK::CLI::ExitWithError, %r{this module is not pdk compatible}i)
end
end

Expand Down

0 comments on commit 1c719d9

Please sign in to comment.