Class: Diffend::BundleSecure

Inherits:
Object
  • Object
show all
Defined in:
lib/diffend/bundle_secure.rb

Overview

Extend bundler with a new secure command to be able to run Diffend separately

Instance Method Summary collapse

Instance Method Details

#exec(_name, _args) ⇒ Object

Execute diffend check

Parameters:

  • _name (String)

    command name

  • _args (Array)

    arguments from ARGV



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/diffend/bundle_secure.rb', line 12

def exec(_name, _args)
  config = Diffend::Config.new(
    command: Diffend::Commands::SECURE,
    severity: Diffend::Logger::INFO
  )

  Diffend::LatestVersion.call(config)

  return unless config.execute?

  unless config.valid?
    config.print_errors

    exit 255
  end

  Diffend::Execute.call(config)
rescue Diffend::Errors::HandledException
  # config will not be initialized when configuration file is missing
  return if config&.ignore_errors?

  exit 255
rescue StandardError => e
  Diffend::HandleErrors::Report.call(
    exception: e,
    config: config,
    message: :unhandled_exception,
    report: true,
    raise_exception: false
  )

  return if config.ignore_errors?

  exit 255
end