Created
July 10, 2017 08:29
-
-
Save chrmoritz/f392d8ac8c66e008ddb660ae9ebb4065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "language/node" | |
class NowCli < Formula | |
desc "The command-line interface for realtime global deployments." | |
homepage "https://zeit.co/now" | |
url "https://github.com/zeit/now-cli/archive/7.0.2.tar.gz" | |
sha256 "7924feb98f07a599cb9ffdabd07f95048864cf4fe15fdcbd2922b8cd8b32a8be" | |
depends_on "node" => :build | |
def install | |
inreplace "package.json" do |s| | |
s.gsub! /^.*"prepublish".*$/, '' # don't run prepublish | |
s.gsub! /^.*"postinstall".*$/, '' # don't run postinstall | |
end | |
# replace update notice message | |
# ToDo: Mabe disbale update notifier completly? | |
inreplace "bin/now.js", "Please download binaries from https://zeit.co/download", | |
"Please update with: brew upgrade now-cli" | |
# Read the target node version from package.json | |
target = IO.read("package.json").match(/\"(node\d+)-macos-x64\"/)[1] | |
system "npm", "install", *Language::Node.local_npm_install_args | |
# This packages now-cli together with a patched version of node (7 atm) | |
# Said version of node is build from source in this install step | |
# The homebrew provided node8 is only used as a build tool. | |
pkg_args = %W[ | |
--config=package.json | |
--output=packed/now | |
--debug | |
--build | |
--targets=#{target} | |
] | |
system "node_modules/.bin/pkg", "bin/now.js", *pkg_args | |
# This is a 58MB big executable containing said patched node7 version + all JavaScript | |
# sources of now-cli and dependencies packed into it. | |
bin.install "packed/now" | |
end | |
test do | |
system "#{bin}/now", "-v" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment