Class: Harbinger::Analyzers::NodeDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/harbinger/analyzers/node_detector.rb

Instance Method Summary collapse

Constructor Details

#initialize(project_path) ⇒ NodeDetector

Returns a new instance of NodeDetector.



9
10
11
# File 'lib/harbinger/analyzers/node_detector.rb', line 9

def initialize(project_path)
  @project_path = project_path
end

Instance Method Details

#detectObject



13
14
15
16
17
18
# File 'lib/harbinger/analyzers/node_detector.rb', line 13

def detect
  detect_from_version_files ||
    detect_from_package_json ||
    detect_from_docker_compose ||
    (nodejs_detected? ? detect_from_shell : nil)
end

#nodejs_detected?Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
28
# File 'lib/harbinger/analyzers/node_detector.rb', line 20

def nodejs_detected?
  File.exist?(File.join(project_path, "package.json")) ||
    File.exist?(File.join(project_path, "package-lock.json")) ||
    File.exist?(File.join(project_path, ".nvmrc")) ||
    File.exist?(File.join(project_path, ".node-version")) ||
    File.exist?(File.join(project_path, "node_modules"))
rescue StandardError
  false
end