diff --git a/Formula/h/heroku.rb b/Formula/h/heroku.rb new file mode 100644 index 0000000000000..febfc03f0ba04 --- /dev/null +++ b/Formula/h/heroku.rb @@ -0,0 +1,36 @@ +class Heroku < Formula + desc "CLI for Heroku" + homepage "https://www.npmjs.com/package/heroku/" + url "https://registry.npmjs.org/heroku/-/heroku-9.5.1.tgz" + sha256 "1dd66255bdc57f742c091671b2f84f6ee4faca8b9bd967d8528678182cf2a6b5" + license "ISC" + + depends_on "node" + depends_on "terminal-notifier" + + def install + system "npm", "install", *std_npm_args + bin.install_symlink Dir["#{libexec}/bin/*"] + + node_modules = libexec/"lib/node_modules/heroku/node_modules" + # Remove vendored pre-built binary `terminal-notifier` + node_notifier_vendor_dir = node_modules/"node-notifier/vendor" + rm_r(node_notifier_vendor_dir) # remove vendored pre-built binaries + + if OS.mac? + terminal_notifier_dir = node_notifier_vendor_dir/"mac.noindex" + terminal_notifier_dir.mkpath + + # replace vendored `terminal-notifier` with our own + terminal_notifier_app = Formula["terminal-notifier"].opt_prefix/"terminal-notifier.app" + ln_sf terminal_notifier_app.relative_path_from(terminal_notifier_dir), terminal_notifier_dir + end + + # Replace universal binaries with their native slices. + deuniversalize_machos + end + + test do + assert_match "Error: not logged in", shell_output("#{bin}/heroku auth:whoami 2>&1", 100) + end +end