Skip to content

XDG Compliance #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 10, 2021
Merged

XDG Compliance #14

merged 3 commits into from
May 10, 2021

Conversation

BurnerWah
Copy link
Contributor

I'm not entirely sure if this is the best way to implement this, TBH. Can't really test things on Windows that easily.

This changes the code to use $XDG_RUNTIME_DIR/$CORE_D_DOTFILE on Linux, and falls back upon $HOME/$CORE_D_DOTFILE.
On Windows, it uses $TEMP/$CORE_D_DOTFILE, and falls back upon $USERPROFILE/$CORE_D_DOTFILE.

I noticed that Node has os.tmpdir and os.homedir, which might be simpler than checking the environment variables. There'd still need to be an XDG check included with that, but it might be able to remove the home_env variable.
That having been said, I have no idea if Windows path separators would affect this.

I'm also not sure if there's an appropriate default on macOS. As it stands, I think it would always end up using $HOME/$CORE_D_DOTFILE.

And I'm not sure whether this should use a subdirectory of the temp dir, or the temp dir directly.

I'm fine with changing anything in this.

Fixes #13, mantoni/eslint_d.js#158 (eventually)

I don't think it's very pretty right now, and I'm very open to changing
it. Right now it just uses $TEMP on windows, and always falls back to
the old behavior.
@mantoni
Copy link
Owner

mantoni commented May 9, 2021

Thank you for contributing!

I think the way you implemented this is generally fine, as the change is fairly minimal. However, this is changing the default behaviour on Windows – if TEMP is defined, which I belief it usually is.

Can we make this an even smaller change to only check whether $XDG_RUNTIME_DIR is defined, and fall back to the current behaviour otherwise?

I have enabled GitHub actions for PRs on this project on the master branch. Can you rebase? Then we'll have the build running in the supported Node versions. Thanks.

@samhh
Copy link

samhh commented May 9, 2021

My understanding of the XDG spec is that typically the variables aren't overridden or explicitly set and in the standard come with sane defaults. As a rule I'd consider something noncompliant if it doesn't adhere to the spec except when explicitly overridden; for example, in some other projects I've contributed this breaking change towards, the change would typically be to use XDG unless the legacy approach was specifically present/specified in some way.

Having said that I do have $XDG_RUNTIME_DIR set, so maybe the system - at least on Arch - tends to set this one. It'd be worth verifying this.

@BurnerWah
Copy link
Contributor Author

here is the full XDG spec. The relevant part is the following:

If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message. Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.

$XDG_RUNTIME_DIR is one of the few variables without a default. So the current behavior would be a good default to use.

I'll try and rebase the PR later today, and tweak it to just check if $XDG_RUNTIME_DIR is set.

BurnerWah and others added 2 commits May 9, 2021 22:27
Now it just checks if $XDG_RUNTIME_DIR is set, and uses that.
There shouldn't be any change in how things work on windows.
(unless that's set for some reason.)
@mantoni mantoni merged commit 12c60c8 into mantoni:master May 10, 2021
@mantoni
Copy link
Owner

mantoni commented May 10, 2021

📦 Released in v3.2.0. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to have the CORE_D_DOTFILE not stored in $HOME/$USERPROFILE
3 participants