Skip to content

Commit d15af63

Browse files
Merge pull request #267 from michaeltlombardi/ticket/master/FM-8643-rescue-requires
(FM-8643) Ensure library requires fail usefully
2 parents 1f19244 + 448c3ad commit d15af63

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

.rubocop_todo.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2019-10-18 11:01:56 -0500 using RuboCop version 0.49.1.
3+
# on 2019-10-30 10:31:01 -0500 using RuboCop version 0.49.1.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# Offense count: 4
9+
# Offense count: 6
1010
GetText/DecorateFunctionMessage:
1111
Exclude:
1212
- 'lib/puppet/provider/exec/powershell.rb'
1313
- 'lib/puppet/provider/exec/pwsh.rb'
1414
- 'spec/spec_helper_acceptance.rb'
1515

16-
# Offense count: 1
16+
# Offense count: 3
1717
GetText/DecorateString:
1818
Exclude:
1919
- 'lib/puppet/provider/exec/powershell.rb'
20+
- 'lib/puppet/provider/exec/pwsh.rb'

lib/puppet/provider/exec/powershell.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
require 'puppet/provider/exec'
2-
require 'ruby-pwsh'
2+
begin
3+
require 'ruby-pwsh'
4+
rescue LoadError
5+
raise 'Could not load the "ruby-pwsh" library; is the dependency module puppetlabs-pwshlib installed in this environment?'
6+
end
37

48
Puppet::Type.type(:exec).provide :powershell, :parent => Puppet::Provider::Exec do
59
confine :operatingsystem => :windows

lib/puppet/provider/exec/pwsh.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
require 'puppet/provider/exec'
2-
require 'ruby-pwsh'
2+
begin
3+
require 'ruby-pwsh'
4+
rescue LoadError
5+
raise 'Could not load the "ruby-pwsh" library; is the dependency module puppetlabs-pwshlib installed in this environment?'
6+
end
37

48
Puppet::Type.type(:exec).provide :pwsh, :parent => Puppet::Provider::Exec do
59
desc <<-EOT

0 commit comments

Comments
 (0)