-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
77 additions
and
53 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
local utils = require('gh-actions.utils') | ||
local has_rust_module, rust = pcall(require, 'gh-actions.rust') | ||
|
||
local M = {} | ||
|
||
---@param path string | ||
---@return table|nil | ||
function M.read_yaml_file(path) | ||
local yamlstr = utils.read_file(path) | ||
|
||
return M.parse_yaml(yamlstr) | ||
end | ||
|
||
---@param yamlstr string|nil | ||
---@return table|nil | ||
function M.parse_yaml(yamlstr) | ||
if has_rust_module then | ||
return rust.parse_yaml(yamlstr or '') | ||
else | ||
return vim.json.decode(vim.fn.system('yq', yamlstr)) | ||
end | ||
end | ||
|
||
function M.is_yaml_nil(value) | ||
return has_rust_module and value == rust.NIL | ||
end | ||
|
||
return M |