diff options
| author | William Boman <william@redwill.se> | 2022-08-15 21:03:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-15 21:03:06 +0200 |
| commit | 3c62386a396ae0c1cd7adbaacc379eb4af072a65 (patch) | |
| tree | 4d00d20958839a04e6a996c11b97724c762e491a /lua/mason-core/managers/npm/init.lua | |
| parent | chore: update generated code (#295) (diff) | |
| download | mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.gz mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.bz2 mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.lz mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.xz mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.zst mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.zip | |
refactor: introduce selene, harden type defs, and use proper EmmyLua syntax (#296)
Diffstat (limited to 'lua/mason-core/managers/npm/init.lua')
| -rw-r--r-- | lua/mason-core/managers/npm/init.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lua/mason-core/managers/npm/init.lua b/lua/mason-core/managers/npm/init.lua index 5bb2a087..84d9258a 100644 --- a/lua/mason-core/managers/npm/init.lua +++ b/lua/mason-core/managers/npm/init.lua @@ -35,7 +35,7 @@ local function with_receipt(packages) end ---@async ----@param packages { [number]: string, bin: string[] | nil }: The npm packages to install. The first item in this list will be the recipient of the requested version, if set. +---@param packages { [number]: string, bin: string[]? } The npm packages to install. The first item in this list will be the recipient of the requested version, if set. function M.packages(packages) return function() return M.install(packages).with_receipt() @@ -43,7 +43,7 @@ function M.packages(packages) end ---@async ----@param packages { [number]: string, bin: string[] | nil }: The npm packages to install. The first item in this list will be the recipient of the requested version, if set. +---@param packages { [number]: string, bin: string[]? } The npm packages to install. The first item in this list will be the recipient of the requested version, if set. function M.install(packages) local ctx = installer.context() local pkgs = list_copy(packages) @@ -76,21 +76,21 @@ function M.install(packages) end ---@async ----@param exec_args string[]: The arguments to pass to npm exec. +---@param exec_args string[] The arguments to pass to npm exec. function M.exec(exec_args) local ctx = installer.context() ctx.spawn.npm { "exec", "--yes", "--", exec_args } end ---@async ----@param script string: The npm script to run. +---@param script string The npm script to run. function M.run(script) local ctx = installer.context() ctx.spawn.npm { "run", script } end ---@async ----@param receipt InstallReceipt +---@param receipt InstallReceipt<InstallReceiptPackageSource> ---@param install_dir string function M.get_installed_primary_package_version(receipt, install_dir) if receipt.primary_source.type ~= "npm" then @@ -103,7 +103,7 @@ function M.get_installed_primary_package_version(receipt, install_dir) end ---@async ----@param receipt InstallReceipt +---@param receipt InstallReceipt<InstallReceiptPackageSource> ---@param install_dir string function M.check_outdated_primary_package(receipt, install_dir) if receipt.primary_source.type ~= "npm" then @@ -123,8 +123,8 @@ function M.check_outdated_primary_package(receipt, install_dir) if outdated_package.current ~= outdated_package.latest then return { name = primary_package, - current_version = assert(outdated_package.current), - latest_version = assert(outdated_package.latest), + current_version = assert(outdated_package.current, "missing current npm package version"), + latest_version = assert(outdated_package.latest, "missing latest npm package version"), } end end) |
