Class: AppMap::Depends::NodeCLI

Inherits:
NodeCLI show all
Defined in:
lib/appmap/depends/node_cli.rb

Overview

Command wraps the Node depends command.

Constant Summary

Constants inherited from NodeCLI

NodeCLI::APPMAP_JS

Instance Attribute Summary collapse

Attributes inherited from NodeCLI

#appmap_dir, #verbose

Instance Method Summary collapse

Methods inherited from NodeCLI

#command, #detect_nodejs, #index_appmaps

Constructor Details

#initialize(verbose:, appmap_dir:) ⇒ NodeCLI

Returns a new instance of NodeCLI.



15
16
17
18
19
20
# File 'lib/appmap/depends/node_cli.rb', line 15

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

  @base_dir = nil
  @field = 'source_location'
end

Instance Attribute Details

#base_dirObject

Directory name to prefix to the list of modified files which is provided to depends.



11
12
13
# File 'lib/appmap/depends/node_cli.rb', line 11

def base_dir
  @base_dir
end

#fieldObject

AppMap field to report.



13
14
15
# File 'lib/appmap/depends/node_cli.rb', line 13

def field
  @field
end

Instance Method Details

#depends(modified_files = nil) ⇒ Object

Returns the source_location field of every AppMap that is “out of date” with respect to one of the modified_files.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/appmap/depends/node_cli.rb', line 24

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