homebrew-core/Formula/ansible-language-server.rb

43 lines
1.1 KiB
Ruby

require "language/node"
class AnsibleLanguageServer < Formula
desc "Language Server for Ansible Files"
homepage "https://github.com/ansible/ansible-language-server"
url "https://registry.npmjs.org/@ansible/ansible-language-server/-/ansible-language-server-0.9.0.tgz"
sha256 "1bb43a8aa63062b11b8be323d01d062067fe5c0d1ac6c24a10d43b40626f718a"
license "MIT"
bottle do
sha256 cellar: :any_skip_relocation, all: "eb20a83eb8fb9f5a2799e837e941020e655003c1f4a02792ba4f6a1e9af6e292"
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
require "open3"
json = <<~JSON
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"rootUri": null,
"capabilities": {}
}
}
JSON
Open3.popen3("#{bin}/ansible-language-server", "--stdio") do |stdin, stdout|
stdin.write "Content-Length: #{json.size}\r\n\r\n#{json}"
sleep 3
assert_match(/^Content-Length: \d+/i, stdout.readline)
end
end
end