diff options
| author | William Boman <william@redwill.se> | 2022-12-26 17:24:39 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-26 17:24:39 +0100 |
| commit | 5f6a3a30f40721bed47cc288c5516c8b2790103e (patch) | |
| tree | 58af65bec8c51b459839eb4243fc322d6d8b3fde /lua/mason-core/installer/init.lua | |
| parent | feat(expr): add tbl_interpolate() (#805) (diff) | |
| download | mason-5f6a3a30f40721bed47cc288c5516c8b2790103e.tar mason-5f6a3a30f40721bed47cc288c5516c8b2790103e.tar.gz mason-5f6a3a30f40721bed47cc288c5516c8b2790103e.tar.bz2 mason-5f6a3a30f40721bed47cc288c5516c8b2790103e.tar.lz mason-5f6a3a30f40721bed47cc288c5516c8b2790103e.tar.xz mason-5f6a3a30f40721bed47cc288c5516c8b2790103e.tar.zst mason-5f6a3a30f40721bed47cc288c5516c8b2790103e.zip | |
refactor(installer): write debug log file after installation finishes (#806)
Diffstat (limited to 'lua/mason-core/installer/init.lua')
| -rw-r--r-- | lua/mason-core/installer/init.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lua/mason-core/installer/init.lua b/lua/mason-core/installer/init.lua index 4250508c..a11de45d 100644 --- a/lua/mason-core/installer/init.lua +++ b/lua/mason-core/installer/init.lua @@ -107,11 +107,12 @@ function M.execute(handle, opts) local pkg = handle.package local context = InstallContext.new(handle, opts) + local tailed_output = {} if opts.debug then - local append_log = a.scope(function(chunk) - context.fs:append_file("mason-debug.log", chunk) - end) + local function append_log(chunk) + tailed_output[#tailed_output + 1] = chunk + end handle:on("stdout", append_log) handle:on("stderr", append_log) end @@ -149,6 +150,9 @@ function M.execute(handle, opts) permit:forget() handle:close() log.fmt_info("Installation succeeded for %s", pkg) + if opts.debug then + context.fs:write_file("mason-debug.log", table.concat(tailed_output, "")) + end end) :on_failure(function(failure) permit:forget() @@ -162,6 +166,7 @@ function M.execute(handle, opts) fs.async.rmrf(context.cwd:get()) end) else + context.fs:write_file("mason-debug.log", table.concat(tailed_output, "")) context.stdio_sink.stdout( ("[debug] Installation directory retained at %q.\n"):format(context.cwd:get()) ) |
