Class: Bumpit::Managers::Yarn

Inherits:
Base
  • Object
show all
Defined in:
lib/bumpit/managers/yarn.rb

Constant Summary collapse

FILENAMES =
%w(package.json yarn.lock).freeze
OUTDATED_COMMAND =
"npm outdated --json"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

executable?

Class Method Details

.valid?Boolean

Determine if the manager is valid.

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/bumpit/managers/yarn.rb', line 15

def self.valid?
  executable?("npm") &&
    executable?("yarn") &&
    FILENAMES.all? do |filename|
      File.exist?(Pathname.new(Dir.pwd).join(filename))
    end
end

Instance Method Details

#bumpvoid

This method returns an undefined value.

Bump the dependencies, if there are any.



26
27
28
29
30
31
# File 'lib/bumpit/managers/yarn.rb', line 26

def bump
  if outdated.any?
    package_update
    yarn_update
  end
end

#messageString

Return a message for which dependencies were bumped.

Returns:

  • (String)


36
37
38
39
40
# File 'lib/bumpit/managers/yarn.rb', line 36

def message
  if outdated.any?
    "Updates #{to_sentence(outdated.keys.sort)} in JavaScript."
  end
end