Skip to content

Instantly share code, notes, and snippets.

@tongrhj
Last active July 20, 2018 06:46
Show Gist options
  • Save tongrhj/5604a804cc133bf54753343737d19141 to your computer and use it in GitHub Desktop.
Save tongrhj/5604a804cc133bf54753343737d19141 to your computer and use it in GitHub Desktop.
Yarn 1.9.0 Custom Formula for Homebrew (brew)

To install

brew unlink yarn

brew install https://gist.githubusercontent.com/tongrhj/5604a804cc133bf54753343737d19141/raw/cac5605d352fe97848140c6d933f96f31e987122/yarn.rb
class Yarn < Formula
desc "JavaScript package manager"
homepage "https://yarnpkg.com/"
url "https://github.com/yarnpkg/yarn/archive/v1.9.0.tar.gz"
sha256 "dab347923f5415c9b4c98ba3bf595c1d8c5831b7b8bdc9651017e1f69c19f6f7"
bottle :unneeded
depends_on "node" => :recommended
conflicts_with "hadoop", :because => "both install `yarn` binaries"
def install
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
libexec.install Dir["*"]
(bin/"yarn").write_env_script "#{libexec}/bin/yarn.js", :PREFIX => HOMEBREW_PREFIX, :NPM_CONFIG_PYTHON => "/usr/bin/python"
(bin/"yarnpkg").write_env_script "#{libexec}/bin/yarn.js", :PREFIX => HOMEBREW_PREFIX, :NPM_CONFIG_PYTHON => "/usr/bin/python"
inreplace "#{libexec}/package.json", '"installationMethod": "unknown"', '"installationMethod": "homebrew"'
end
test do
(testpath/"package.json").write('{"name": "test"}')
system bin/"yarn", "add", "jquery"
system bin/"yarn", "add", "fsevents", "--build-from-source=true"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment