diff options
| author | mo khan <mo@mokhan.ca> | 2021-12-21 15:22:00 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2021-12-21 15:22:00 -0700 |
| commit | d8d9ce4319bff129aec2a8ee52cdba943b47351d (patch) | |
| tree | 82963ea3f60fef0ff780d591d050a5b6500e97f2 | |
| parent | acd758d7d5adb866a266a05d82f9dc1a33e7450e (diff) | |
feat: update a single dependency
| -rw-r--r-- | lib/dependabot/cli.rb | 3 | ||||
| -rw-r--r-- | lib/dependabot/cli/scan.rb | 8 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/dependabot/cli.rb b/lib/dependabot/cli.rb index 80d01ad..67d6339 100644 --- a/lib/dependabot/cli.rb +++ b/lib/dependabot/cli.rb @@ -7,7 +7,8 @@ require "dependabot/cli/scan" module Dependabot module CLI class Application < Thor - desc "scan [DIRECTORY | FILE]", "Scan a directory or file for dependencies to update" + desc "scan [OPTION]... [FILE]", "Scan a directory or file for dependencies to update" + method_option :dependency, aliases: "-d", type: :string, desc: "Update a specific dependency", default: nil method_option :push, aliases: "-p", type: :boolean, desc: "Push the update as a pull request. Default: --no-push", default: false method_option :recursive, aliases: "-r", type: :boolean, desc: "Perform a recursive. Default: --no-recursive", default: false def scan(path = Pathname.pwd) diff --git a/lib/dependabot/cli/scan.rb b/lib/dependabot/cli/scan.rb index 4c29623..90bf4fb 100644 --- a/lib/dependabot/cli/scan.rb +++ b/lib/dependabot/cli/scan.rb @@ -12,7 +12,7 @@ module Dependabot def run each_dependency do |dependency| - publish_update_for(dependency) + update(dependency) if match?(dependency) end end @@ -30,10 +30,14 @@ module Dependabot end end - def publish_update_for(dependency) + def update(dependency) ::Dependabot.logger.debug("Updating #{dependency.name}…") ::Dependabot::Publish.new(dependency).update!(push: options[:push]) end + + def match?(dependency) + options[:dependency].empty? || options[:dependency].include?(dependency.name) + end end end end |
