homebrew-core/Formula/yarn.rb

47 lines
1.5 KiB
Ruby

class Yarn < Formula
desc "JavaScript package manager"
homepage "https://yarnpkg.com/"
url "https://yarnpkg.com/downloads/1.22.17/yarn-v1.22.17.tar.gz"
sha256 "267982c61119a055ba2b23d9cf90b02d3d16c202c03cb0c3a53b9633eae37249"
license "BSD-2-Clause"
revision 2
livecheck do
skip("1.x line is frozen and features/bugfixes only happen on 2.x")
end
bottle do
sha256 cellar: :any_skip_relocation, all: "28016c8b31dfd51b542168bf0c0165cc7a5e50f0b4034a6cc6628e03f2c01121"
end
depends_on "node" => :test
conflicts_with "hadoop", because: "both install `yarn` binaries"
conflicts_with "corepack", because: "both install `yarn` and `yarnpkg` binaries"
def install
libexec.install buildpath.glob("*")
(bin/"yarn").write_env_script libexec/"bin/yarn.js", PREFIX: HOMEBREW_PREFIX
(bin/"yarnpkg").write_env_script libexec/"bin/yarn.js", PREFIX: HOMEBREW_PREFIX
inreplace libexec/"lib/cli.js", "/usr/local", HOMEBREW_PREFIX
inreplace libexec/"package.json", '"installationMethod": "tar"',
"\"installationMethod\": \"#{tap.user.downcase}\""
end
def caveats
<<~EOS
yarn requires a Node installation to function. You can install one with:
brew install node
EOS
end
test do
(testpath/"package.json").write('{"name": "test"}')
system bin/"yarn", "add", "jquery"
on_macos do
# macOS specific package
system bin/"yarn", "add", "fsevents", "--build-from-source=true"
end
end
end