Sha256: 640d41b23917073974bff36a7b769bd03e31a7833309cc8d076faa09c8b2f9d6

Contents?: true

Size: 1.25 KB

Versions: 88

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'shellwords'
require 'appmap/node_cli'

module AppMap
  module Depends
    # +Command+ wraps the Node +depends+ command.
    class NodeCLI < ::AppMap::NodeCLI
      # Directory name to prefix to the list of modified files which is provided to +depends+.
      attr_accessor :base_dir
      # AppMap field to report.
      attr_accessor :field

      def initialize(verbose:, appmap_dir:)
        super(verbose: verbose, appmap_dir: appmap_dir)

        @base_dir = nil
        @field = 'source_location'
      end

      # Returns the source_location field of every AppMap that is "out of date" with respect to one of the
      # +modified_files+.
      def depends(modified_files = nil)
        index_appmaps

        cmd = %w[depends]
        cmd += [ '--field', field ] if field
        cmd += [ '--appmap-dir', appmap_dir ] if appmap_dir
        cmd += [ '--base-dir', base_dir ] if base_dir

        options = {}
        if modified_files
          cmd << '--stdin-files'
          options[:stdin_data] = modified_files.map(&:shellescape).join("\n")
          warn "Checking modified files: #{modified_files.join(' ')}" if verbose
        end

        stdout, = command cmd, options
        stdout.split("\n")
      end
    end
  end
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
appmap-1.1.1 lib/appmap/depends/node_cli.rb
appmap-1.0.1 lib/appmap/depends/node_cli.rb
appmap-1.0.0 lib/appmap/depends/node_cli.rb
appmap-0.103.0 lib/appmap/depends/node_cli.rb
appmap-0.102.2 lib/appmap/depends/node_cli.rb
appmap-0.102.1 lib/appmap/depends/node_cli.rb
appmap-0.102.0 lib/appmap/depends/node_cli.rb
appmap-0.101.0 lib/appmap/depends/node_cli.rb
appmap-0.100.0 lib/appmap/depends/node_cli.rb
appmap-0.99.4 lib/appmap/depends/node_cli.rb
appmap-0.99.2 lib/appmap/depends/node_cli.rb
appmap-0.99.1 lib/appmap/depends/node_cli.rb
appmap-0.99.0 lib/appmap/depends/node_cli.rb
appmap-0.98.1 lib/appmap/depends/node_cli.rb
appmap-0.98.0 lib/appmap/depends/node_cli.rb
appmap-0.97.0 lib/appmap/depends/node_cli.rb
appmap-0.96.0 lib/appmap/depends/node_cli.rb
appmap-0.95.2 lib/appmap/depends/node_cli.rb
appmap-0.95.1 lib/appmap/depends/node_cli.rb
appmap-0.95.0 lib/appmap/depends/node_cli.rb