update-notifier icon indicating copy to clipboard operation
update-notifier copied to clipboard

Better adhere to XDG specification

Open skipkayhil opened this issue 4 years ago • 3 comments

Spec for reference

Currently, any package that uses update-notifier results in an update-notifier-<package>.json being put in $XDG_CONFIG_HOME.

As someone who symlinks my $XDG_CONFIG_HOME into my dotfiles repository, this leads to undesired behavior. These are not files that I want in my dotfiles, nor do I think they would be useful to keep in sync across multiple devices. I believe the data stored here would be more appropriate in $XDG_DATA_HOME or $XDG_CACHE_HOME

skipkayhil avatar Apr 08 '20 21:04 skipkayhil

I agree. Should be “data”, not “cache”.

sindresorhus avatar Apr 09 '20 04:04 sindresorhus

I can create a PR for this, do you have a recommended way to do it? The simplest is probably passing in the new configPath to configstore.

skipkayhil avatar Apr 14 '20 20:04 skipkayhil

This would be a welcome addition. I think XDG_STATE_HOME would make more sense, however, since this data isn't portable across machines (as would be expected with XDG_DATA_HOME), but also isn't entirely non-essential (as with XDG_CACHE_HOME):

The $XDG_STATE_HOME contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in $XDG_DATA_HOME. It may contain:

actions history (logs, history, recently used files, …)

current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

{
	"optOut": false,
	"lastUpdateCheck": 1634843835359,
	"update": {
		"latest": "8.1.0",
		"current": "6.14.11",
		"type": "major",
		"name": "npm"
	}
}

There's a node library that abstracts away most of the logic: https://www.npmjs.com/package/xdg-basedir

Happy to submit a PR for this if there's still support for it.

import {xdgData, xdgConfig, xdgDataDirectories} from 'xdg-basedir';

console.log(xdgData);
//=> '/home/sindresorhus/.local/share'

console.log(xdgConfig);
//=> '/home/sindresorhus/.config'

console.log(xdgDataDirectories);
//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/']

jmromer avatar Nov 05 '21 11:11 jmromer