Ensure that an empty invocation does not trigger the license check

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2019-02-15 11:05:49 -05:00
parent e0fe3f1876
commit f7c4f56670
2 changed files with 3 additions and 2 deletions

View file

@ -390,7 +390,8 @@ commands_exempt_from_license_check = help_commands + version_commands
#---------------------------------------------------------------------#
require 'license_acceptance/acceptor'
begin
if (commands_exempt_from_license_check & ARGV.map(&:downcase)).empty?
if (commands_exempt_from_license_check & ARGV.map(&:downcase)).empty? && # Did they use a non-exempt command?
!ARGV.empty? # Did they supply at least one command?
LicenseAcceptance::Acceptor.check_and_persist('inspec', Inspec::VERSION)
end
rescue LicenseAcceptance::LicenseNotAcceptedError

View file

@ -85,7 +85,7 @@ describe 'The license acceptance mechanism' do
describe 'when a command is used that should not be gated on licensure' do
[
'-h', '--help', 'help',
'-h', '--help', 'help', '', # Empty invocation is treated as `inspec help`
'-v', '--version', 'version',
].each do |ungated_invocation|
it "should not challenge for a license when running `inspec #{ungated_invocation}`" do