Class: NpmCommands
- Inherits:
-
Object
- Object
- NpmCommands
- Defined in:
- lib/npm_commands.rb
Overview
NPM wrapper with helpful error messages
Instance Method Summary collapse
-
#install(*args) ⇒ Boolean
Whether the installation succeeded.
-
#update(*args) ⇒ Boolean
Whether the update succeeded.
Instance Method Details
#install(*args) ⇒ Boolean
Returns 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) # rubocop:disable Metrics/MethodLength return false unless check_nodejs_installed STDERR.puts 'Installing npm dependencies...' success = in_gem_root do system('npm', 'install', *args) end STDERR.puts( *if success ['npm dependencies installed'] else ['-' * 60, 'Error: npm dependencies installation failed', '-' * 60] end ) success end |
#update(*args) ⇒ Boolean
Returns whether the update succeeded.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/npm_commands.rb', line 25 def update(*args) # rubocop:disable Metrics/MethodLength return false unless check_nodejs_installed STDERR.puts 'Updating npm dependencies...' success = in_gem_root do system('npm', 'update', *args) end STDERR.puts( *if success ['npm dependencies updated'] else ['-' * 60, 'Error: npm dependencies update failed', '-' * 60] end ) success end |