-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathinit.lua
More file actions
27 lines (22 loc) · 774 Bytes
/
init.lua
File metadata and controls
27 lines (22 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local helpers = require('runner.handlers.helpers')
local utils = require('runner.handlers.utils')
return function(buffer)
utils.run_command(utils.script_path() .. 'get-scripts.sh', function(output)
local bins = {}
for _, line in pairs(output) do
for _, data in pairs(line) do
if vim.trim(data) ~= '' and not string.match(data, 'npm ERR!') then
bins[#bins + 1] = data
end
end
end
local handlers = {
['Run current file'] = helpers.shell_handler('node ' .. vim.fn.expand('%')),
['Custom'] = helpers.shell_handler('npm ', true),
}
for _, bin in pairs(bins) do
handlers['Run "' .. bin .. '"'] = helpers.shell_handler('npm run ' .. bin)
end
helpers.choice(handlers)(buffer)
end)
end