homebrew-core/Formula/codemod.rb

49 lines
1.5 KiB
Ruby

class Codemod < Formula
include Language::Python::Virtualenv
desc "Large-scale codebase refactors assistant tool"
homepage "https://github.com/facebook/codemod"
url "https://files.pythonhosted.org/packages/9b/e3/cb31bfcf14f976060ea7b7f34135ebc796cde65eba923f6a0c4b71f15cc2/codemod-1.0.0.tar.gz"
sha256 "06e8c75f2b45210dd8270e30a6a88ae464b39abd6d0cab58a3d7bfd1c094e588"
license "Apache-2.0"
revision 3
version_scheme 1
head "https://github.com/facebook/codemod.git"
livecheck do
url :stable
end
bottle do
cellar :any_skip_relocation
sha256 "3b32fef1fef317a4544225f6de58e0c1e970de6deb10258fe2d3f937116d5468" => :catalina
sha256 "da2eee278c0136d201d2c59db1876f90996600c8a00a0c2434742015846d7457" => :mojave
sha256 "31f1ef7e3e6867ef52f0922c807762363b3a4f1c520b0de5bbd448282f95a5e5" => :high_sierra
end
depends_on "python@3.8"
def install
virtualenv_install_with_resources
end
test do
# work around some codemod terminal bugs
ENV["TERM"] = "xterm"
ENV["LINES"] = "25"
ENV["COLUMNS"] = "80"
(testpath/"file1").write <<~EOS
foo
bar
potato
baz
EOS
(testpath/"file2").write <<~EOS
eeny potato meeny miny moe
EOS
system bin/"codemod", "--include-extensionless", "--accept-all", "potato", "pineapple"
assert_equal %w[foo bar pineapple baz], File.read("file1").lines.map(&:strip)
assert_equal ["eeny pineapple meeny miny moe"], File.read("file2").lines.map(&:strip)
end
end