Sha256: d5360b4013fed0e4395090bb7f038013cd67ff2d018ad5429e77f0055826622f

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Diffend
  # Extend bundler with a new secure command to be able to run Diffend separately
  class BundleSecure
    ::Bundler::Plugin::API.command(Diffend::Commands::SECURE, self)

    # Execute diffend check
    #
    # @param _name [String] command name
    # @param _args [Array] arguments from ARGV
    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
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
diffend-0.2.54 lib/diffend/bundle_secure.rb
diffend-monitor-0.2.54 lib/diffend/bundle_secure.rb
diffend-0.2.53 lib/diffend/bundle_secure.rb
diffend-monitor-0.2.51 lib/diffend/bundle_secure.rb
diffend-0.2.51 lib/diffend/bundle_secure.rb