dev-cmd/typecheck: Make an --update switch for automatic updates

- This was suggested in https://github.com/Homebrew/brew/pull/8741#discussion_r490949486.
This commit is contained in:
Issy Long 2020-09-18 16:01:02 +01:00
parent d9416d762a
commit bb0fc2764e
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
3 changed files with 11 additions and 19 deletions

View File

@ -16,10 +16,8 @@ module Homebrew
EOS
switch "-q", "--quiet",
description: "Silence all non-critical errors."
switch "--update-definitions",
description: "Update Tapioca gem definitions of recently bumped gems"
switch "--prune-files-list",
description: "Remove deleted filepaths from #{SORBET_FILES_YAML}"
switch "--update",
description: "Update RBI files and prune #{SORBET_FILES_YAML}"
switch "--fail-if-not-changed",
description: "Return a failing status code if all gems are up to date " \
"and gem definitions do not need a tapioca update"
@ -41,7 +39,8 @@ module Homebrew
Homebrew.install_bundler_gems!
HOMEBREW_LIBRARY_PATH.cd do
if args.prune_files_list?
if args.update?
ohai "Checking for deleted filenames in #{SORBET_FILES_YAML}..."
lines_to_keep = []
sorbet_keywords = ["true:", "false:", "strict:", "strong:"]
@ -52,12 +51,11 @@ module Homebrew
filepath = line.split(" ").last
lines_to_keep << line if File.exist?(filepath)
end
end
File.write(SORBET_FILES_YAML, "#{lines_to_keep.join("\n")}\n")
end
if args.update_definitions?
ohai "Updating Tapioca RBI files..."
system "bundle", "exec", "tapioca", "sync"
system "bundle", "exec", "srb", "rbi", "hidden-definitions"
system "bundle", "exec", "srb", "rbi", "todo"

View File

@ -1244,10 +1244,8 @@ Check for typechecking errors using Sorbet.
* `-q`, `--quiet`:
Silence all non-critical errors.
* `--update-definitions`:
Update Tapioca gem definitions of recently bumped gems
* `--prune-files-list`:
Remove deleted filepaths from sorbet/files.yaml
* `--update`:
Update RBI files and prune sorbet/files.yaml
* `--fail-if-not-changed`:
Return a failing status code if all gems are up to date and gem definitions do not need a tapioca update
* `--dir`:

View File

@ -1718,12 +1718,8 @@ Check for typechecking errors using Sorbet\.
Silence all non\-critical errors\.
.
.TP
\fB\-\-update\-definitions\fR
Update Tapioca gem definitions of recently bumped gems
.
.TP
\fB\-\-prune\-files\-list\fR
Remove deleted filepaths from sorbet/files\.yaml
\fB\-\-update\fR
Update RBI files and prune sorbet/files\.yaml
.
.TP
\fB\-\-fail\-if\-not\-changed\fR