Aleph-Alpha / ts-rs

Generate TypeScript bindings from Rust types
MIT License
1.08k stars 107 forks source link

Use `std::path::absolute` #333

Closed gustavo-shigueo closed 3 months ago

gustavo-shigueo commented 3 months ago

Goal

Replace our hand implemented absolute path generator with the one provided by the Rust std lib Closes #332

Checklist

gustavo-shigueo commented 3 months ago

It appears that the std::path::absolute function only removes .. components from paths on windows

/// The path is resolved using [POSIX semantics][posix-semantics] except that /// it stops short of resolving symlinks. This means it will keep .. /// components and trailing slashes.

NyxCode commented 3 months ago

Ah, that sucks. I vaguely recall that there also was some reason we couldn't use std::fs::canonicalize, so idk. - maybe we should just keep it as-is? 😅

gustavo-shigueo commented 3 months ago

std::fs::canonicalize requires the path to already exist, so it can't be used to create files or directories