Class: NpmCommands

Inherits:
Object
  • Object
show all
Defined in:
lib/npm_commands.rb

Overview

NPM wrapper with helpful error messages

Instance Method Summary collapse

Instance Method Details

#install(*args) ⇒ Boolean

Returns whether the installation succeeded.

Returns:

  • (Boolean)

    whether the installation succeeded



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/npm_commands.rb', line 6

def install(*args)
  return false unless check_nodejs_installed
  STDERR.puts 'Installing npm dependencies...'
  install_status = Dir.chdir File.expand_path('..', File.dirname(__FILE__)) do
    system('npm', 'install', *args)
  end
  STDERR.puts(
    *if install_status
       ['npm dependencies installed']
     else
       ['-' * 60,
        'Error: npm dependencies installation failed',
        '-' * 60]
     end
  )
  install_status
end