require "language/node" class WebtorrentCli < Formula desc "Command-line streaming torrent client" homepage "https://webtorrent.io/" url "https://registry.npmjs.org/webtorrent-cli/-/webtorrent-cli-3.0.0.tgz" sha256 "beb26d0dd4cacdf09042a997c68a30d61577dc920936462669188fe4a74c3581" bottle do sha256 "763b25ec1afb357d3164ebb14f8fcd587faff15161f89b075ca5be496c4a9116" => :mojave sha256 "d06fbde070d023361b5d4ad0469c9f8fa765c55273ea9ad365796f41386a5329" => :high_sierra sha256 "329f669b198a61a071a67a5fd6ee896b5168be8a67bf12cdf913338d730af2c0" => :sierra end depends_on "node" def install system "npm", "install", *Language::Node.std_npm_install_args(libexec) bin.install_symlink Dir["#{libexec}/bin/*"] end test do magnet_uri = <<~EOS.gsub(/\s+/, "").strip magnet:?xt=urn:btih:9eae210fe47a073f991c83561e75d439887be3f3 &dn=archlinux-2017.02.01-x86_64.iso &tr=udp://tracker.archlinux.org:6969 &tr=https://tracker.archlinux.org:443/announce EOS assert_equal <<~EOS.chomp, shell_output("#{bin}/webtorrent info '#{magnet_uri}'") { "xt": "urn:btih:9eae210fe47a073f991c83561e75d439887be3f3", "dn": "archlinux-2017.02.01-x86_64.iso", "tr": [ "https://tracker.archlinux.org:443/announce", "udp://tracker.archlinux.org:6969" ], "infoHash": "9eae210fe47a073f991c83561e75d439887be3f3", "name": "archlinux-2017.02.01-x86_64.iso", "announce": [ "https://tracker.archlinux.org:443/announce", "udp://tracker.archlinux.org:6969" ], "urlList": [] } EOS end end