aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/composer.lua
blob: e67d523b6ea306dc9566671701e83820083ad5d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local M = {}

M.query = function (path)
    if vim.fn.findfile("composer.json") == "" then
        P("did not found the file")
        return nil
    end

    local target = vim.fn.json_decode(vim.fn.readfile(vim.fn.getcwd() .. "/composer.json"))

    for _, part in ipairs(path) do
        target = target[part]
        if target == nil then
            return nil
        end
    end

    return target
end

return M