Class: NewlineHw::Shell::Runners::Javascript

Inherits:
Base
  • Object
show all
Defined in:
lib/newline_hw/shell/runners/javascript.rb

Overview

Build a shell command that is dependent on files of a project being present that are UNOPINIONATED about how to setup / start a JS project

Instance Attribute Summary

Attributes inherited from Base

#commands, #pwd

Instance Method Summary collapse

Methods inherited from Base

#add_command, #file?, #file_contents?, #file_path, get_commands, #initialize

Constructor Details

This class inherits a constructor from NewlineHw::Shell::Runners::Base

Instance Method Details

#npm?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/newline_hw/shell/runners/javascript.rb', line 8

def npm?
  file?("package.json")
end

#prepare_commandsObject



16
17
18
19
# File 'lib/newline_hw/shell/runners/javascript.rb', line 16

def prepare_commands
  add_command "yarn" if yarn?
  add_command "npm install" if npm? && !yarn?
end

#yarn?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/newline_hw/shell/runners/javascript.rb', line 12

def yarn?
  file?("yarn.lock")
end