From 78264fb9350814c32ca9442ff3113e15a8218dad Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 15 Feb 2023 17:07:57 +0100 Subject: [PATCH] style: added proper types to process --- lua/lazy/manage/process.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lua/lazy/manage/process.lua b/lua/lazy/manage/process.lua index fd5f898..530aeaa 100644 --- a/lua/lazy/manage/process.lua +++ b/lua/lazy/manage/process.lua @@ -2,7 +2,7 @@ local Config = require("lazy.core.config") local M = {} ----@type table +---@type table M.running = {} M.signals = { @@ -57,28 +57,31 @@ function M.spawn(cmd, opts) opts = opts or {} opts.timeout = opts.timeout or (Config.options.git and Config.options.git.timeout * 1000) + ---@type table local env = vim.tbl_extend("force", { GIT_SSH_COMMAND = "ssh -oBatchMode=yes", }, uv.os_environ(), opts.env or {}) env.GIT_DIR = nil env.GIT_TERMINAL_PROMPT = "0" + ---@type string[] local env_flat = {} for k, v in pairs(env) do env_flat[#env_flat + 1] = k .. "=" .. v end - local stdout = uv.new_pipe() - local stderr = uv.new_pipe() + local stdout = assert(uv.new_pipe()) + local stderr = assert(uv.new_pipe()) local output = "" - ---@type vim.loop.Process + ---@type uv.uv_process_t local handle = nil + ---@type uv.uv_timer_t local timeout local killed = false if opts.timeout then - timeout = uv.new_timer() + timeout = assert(uv.new_timer()) timeout:start(opts.timeout, 0, function() if M.kill(handle) then killed = true @@ -100,7 +103,7 @@ function M.spawn(cmd, opts) handle:close() stdout:close() stderr:close() - local check = uv.new_check() + local check = assert(uv.new_check()) check:start(function() if not stdout:is_closing() or not stderr:is_closing() then return