dsherret / dax

Cross-platform shell tools for Deno and Node.js inspired by zx.
MIT License
1.02k stars 34 forks source link

`PathRef.writeText()` is broken with `append: true` option #157

Closed greentore closed 1 year ago

greentore commented 1 year ago

Steps to reproduce

import  { $ } from "https://deno.land/x/dax@0.33.0/mod.ts";
const ref = $.path(".").resolve().join("test.log");
await ref.writeText("test", { append: true });

Outcome

Uncaught TypeError: Invalid argument (os error 22): open '/home/admin/test.log'
    at async Object.open (ext:deno_fs/30_fs.js:576:15)
    at async PathRef.#openFileForWriting (https://deno.land/x/dax@0.33.0/src/path.ts:650:14)
    at async PathRef.#withFileForWriting (https://deno.land/x/dax@0.33.0/src/path.ts:634:18)
    at async PathRef.writeText (https://deno.land/x/dax@0.33.0/src/path.ts:583:5)
    at async <anonymous>:4:1
sigmaSd commented 1 year ago

Its because writeText truncate by default, https://github.com/dsherret/dax/blob/main/src/path.ts#L650

Are those default options needed ?

dsherret commented 1 year ago

I think they're necessary in order to say the default options for writing.