From 49124e93205c8d8096a6cf0a519fc70de4146e9a Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Sat, 20 Jul 2024 16:39:59 +0200 Subject: [PATCH] fix: cd back to project root after build in case of another build --- src/luarocks/build/treesitter-parser.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/luarocks/build/treesitter-parser.lua b/src/luarocks/build/treesitter-parser.lua index a038f55..a181f62 100644 --- a/src/luarocks/build/treesitter-parser.lua +++ b/src/luarocks/build/treesitter-parser.lua @@ -56,6 +56,7 @@ function treesitter_parser.run(rockspec, no_install) return nil, "'tree-sitter CLI' is not installed.\n" .. rockspec.name .. " requires the tree-sitter CLI to build.\n" end + local project_root = fs.absolute_name(dir.path(".")) if build.generate then local js_runtime = os.getenv("TREE_SITTER_JS_RUNTIME") or "node" local js_runtime_name = js_runtime == "node" and "Node JS" or js_runtime @@ -172,6 +173,10 @@ function treesitter_parser.run(rockspec, no_install) fs.make_dir(dest) ok, err = fs.copy_contents(parser_dir, dest) end + if build.location then + -- Change back to project root in case of another build + fs.change_dir(project_root) + end return ok, err end