add TSamFile and TSamAll command with default keymaps
This commit is contained in:
@@ -220,6 +220,7 @@ function M.new(opts)
|
||||
runner.name = cfg.name or "js"
|
||||
runner.framework = cfg.framework or "jest"
|
||||
runner.command = cfg.command or { "npx", runner.framework }
|
||||
runner.all_glob = cfg.all_glob
|
||||
|
||||
runner.filetypes = {}
|
||||
if cfg.filetypes then
|
||||
@@ -312,6 +313,62 @@ function M.new(opts)
|
||||
}
|
||||
end
|
||||
|
||||
function runner.build_file_command(bufnr)
|
||||
local path = util.get_buf_path(bufnr)
|
||||
if not path or path == "" then
|
||||
return nil
|
||||
end
|
||||
local root
|
||||
if runner.framework == "jest" then
|
||||
root = find_jest_root(path)
|
||||
else
|
||||
root = util.find_root(path, {
|
||||
"jest.config.js",
|
||||
"jest.config.ts",
|
||||
"vitest.config.ts",
|
||||
"vitest.config.js",
|
||||
"package.json",
|
||||
"node_modules",
|
||||
})
|
||||
end
|
||||
local cmd = vim.deepcopy(runner.command)
|
||||
table.insert(cmd, path)
|
||||
return {
|
||||
cmd = cmd,
|
||||
cwd = root,
|
||||
}
|
||||
end
|
||||
|
||||
function runner.build_all_command(bufnr)
|
||||
local path = util.get_buf_path(bufnr)
|
||||
local root
|
||||
if path and path ~= "" then
|
||||
if runner.framework == "jest" then
|
||||
root = find_jest_root(path)
|
||||
else
|
||||
root = util.find_root(path, {
|
||||
"jest.config.js",
|
||||
"jest.config.ts",
|
||||
"vitest.config.ts",
|
||||
"vitest.config.js",
|
||||
"package.json",
|
||||
"node_modules",
|
||||
})
|
||||
end
|
||||
end
|
||||
if not root or root == "" then
|
||||
root = vim.loop.cwd()
|
||||
end
|
||||
local cmd = vim.deepcopy(runner.command)
|
||||
if runner.framework == "mocha" and runner.all_glob then
|
||||
table.insert(cmd, runner.all_glob)
|
||||
end
|
||||
return {
|
||||
cmd = cmd,
|
||||
cwd = root,
|
||||
}
|
||||
end
|
||||
|
||||
return runner
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user