deno: Deno saves file in the wrong place

When I try to use writeAll/Deno.open, it saves in the wrong place. Entire code can be found here

Code

import { ensureDirSync } from "https://deno.land/std@0.80.0/fs/ensure_dir.ts";
import { join, parse } from "https://deno.land/std@0.80.0/path/mod.ts";

const encoder  = new TextEncoder();
const text = encoder.encode("somebody save me");
const savePath = join('logs', `file.log`);

ensureDirSync(parse(savePath).dir);

const file = Deno.openSync(savePath, { write:true, create:true, append:true });
Deno.writeAllSync(file, text);
Deno.close(file.rid);

It saves at:

C:\VTRoot\HarddiskVolume4\documentos\projetos\javascript\deno\binance\logs

Instead of (where the project is at)

D:\documentos\projetos\javascript\deno\binance

I also tried appending Deno.cwd() to the join command

Config

deno version: 1.6.0 windows: 10.0.18363 Compilação 18363

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 27 (11 by maintainers)

Most upvoted comments

I tried replicating it on windows, running the script from my D drive. Couldn’t replicate.

Example of what i did:

PS D:\Development\ebebbington\some-repo> touch a.ts # then added the code above to the file
PS ... > deno run -A a.ts
PS ... > ls
a.ts logs
PS ... > ls logs
file.log

Deno version 1.6.0