Skip to content

1.2.0

Choose a tag to compare

@Pinta365 Pinta365 released this 25 Sep 17:03
· 10 commits to main since this release

@cross/dir 1.2.0

Linux: user directories now work out of the box

download, document, audio, picture, video, desktop, public and template previously only resolved if
their XDG_*_DIR environment variable was set, which most desktop sessions don't do. They are now also read from
the xdg-user-dirs file $XDG_CONFIG_HOME/user-dirs.dirs
(default ~/.config/user-dirs.dirs). Environment variables still take precedence.

Entries pointing to the home directory itself (e.g. XDG_DESKTOP_DIR="$HOME/") are treated as disabled, per the
xdg-user-dirs spec, and still throw.

New directory types

  • projects (Linux): resolves XDG_PROJECTS_DIR, added in xdg-user-dirs 0.19.
  • state (all platforms): for persistent application state such as logs and history.
    • Linux: $XDG_STATE_HOME, falling back to ~/.local/state
    • macOS: ~/Library/Application Support
    • Windows: %LOCALAPPDATA%

Fixes

  • Windows: the PowerShell fallback for config (dir("config", true) with APPDATA unset) now returns the
    roaming ApplicationData folder instead of LocalApplicationData, consistent with APPDATA and data.
  • Windows: tmp now falls back to TEMP when TMP is unset.

Internal

  • Added a test suite (deno task test), including a platform smoke test that resolves every directory type.
  • Removed the unused @cross/deepmerge dependency.
  • Fixed the check-deps task flag (--ignore-unused → --allow-unused) so deno task check passes.
  • README: added error handling and development sections, and fixed the usage example's missing DirectoryTypes import.

Upgrade impact: nothing needs to change for most people. The one exception is a Windows call to dir("config", true) on a machine where APPDATA isn't set. Before, that returned ...\AppData\Local; now it returns ...\AppData\Roaming. That's rare, since Windows normally sets APPDATA, but anyone who relied on the old path would stop finding files they stored there.