Here is the issue with traceback 
````
[smoke] > quarto render docs\smoke-all\2022\09\30\custom-writer-emulation\customwriter-yaml.qmd --to customformat.lua => ./test.ts:126:72
error: AssertionError: Failed assertion:

--------------------------------------------------------------------------------
[smoke] > quarto render docs\smoke-all\2022\09\30\custom-writer-emulation\customwriter-yaml.qmd --to customformat.lua
          run-tests.psl ..\..\..\..\..\..\C:\Users\chris\Documents\DEV_R\quarto-cli\tests\smoke\smoke-all.test.ts

[verify] > unknown

La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte. (os error 123), stat 'docs\smoke-all\2022\09\30\custom-writer-emulation\customwriter-yaml_files\figure-C:\Users\chris\Documents\DEV_R\quarto'
Error: La syntaxe du nom de fichier, de répertoire ou de volume est incorrecte. (os error 123), stat 'docs\smoke-all\2022\09\30\custom-writer-emulation\customwriter-yaml_files\figure-C:\Users\chris\Documents\DEV_R\quarto'
    at Object.lstatSync (deno:runtime/js/30_fs.js:305:9)
    at existsSync (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/vendor/deno.land/std@0.166.0/fs/exists.ts:75:10)
    at removeIfEmptyDir (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/core/path.ts:47:7)
    at renderCleanup (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/cleanup.ts:101:3)
    at file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render.ts:293:9
    at withTiming (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/core/timing.ts:37:20)
    at Object.complete (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render.ts:292:7)
    at async Object.onPostProcess (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-files.ts:568:28)
    at async renderFiles (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-files.ts:524:7)
    at async render (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-shared.ts:101:18)
````

We are building wrong path above `docs\smoke-all\2022\09\30\custom-writer-emulation\customwriter-yaml_files\figure-C:\Users\chris\Documents\DEV_R\quarto`  by appending to path not correctly. 

The issue is from 
https://github.com/quarto-dev/quarto-cli/blob/104d39d2da77bdbf38cc37f33b29eb75dd23b8e7/src/command/render/cleanup.ts#L33-L36

as `format.pandoc.to` is a path. I have this in debug mode console
````
> figureFormat
'C:\Users\chris\Documents\DEV_R\quarto-cli\src\resources\filters\customwriter\customwriter.lua'
````

This leads to wrong figure directory created 
https://github.com/quarto-dev/quarto-cli/blob/104d39d2da77bdbf38cc37f33b29eb75dd23b8e7/src/command/render/cleanup.ts#L96-L97


Maybe the issue is elsewhere though but here the empty directory are deleted even on Linux (no error on Linux , only windows)
cderv
2023-02-07T17:00:44Z
cderv
v1.3
closed
Wrong figure folder built using custom format due to mutation
https://github.com/quarto-dev/quarto-cli/issues/4260