What is xdg-basedir?
The xdg-basedir package is a Node.js module that provides access to the XDG Base Directory Specification paths. It allows developers to easily find standard directories like configuration, data, and cache directories according to the XDG standards, which are commonly used in various Linux distributions.
What are xdg-basedir's main functionalities?
Access to XDG Config Directory
This feature allows developers to retrieve the path to the user's XDG config directory, which is used to store configuration files.
const xdgBasedir = require('xdg-basedir');
console.log(xdgBasedir.config);
Access to XDG Data Directory
This feature provides the path to the XDG data directory, where applications can store data files.
const xdgBasedir = require('xdg-basedir');
console.log(xdgBasedir.data);
Access to XDG Cache Directory
This feature retrieves the path to the XDG cache directory, which is intended for non-essential data files.
const xdgBasedir = require('xdg-basedir');
console.log(xdgBasedir.cache);
Other packages similar to xdg-basedir
env-paths
Similar to xdg-basedir, env-paths computes paths for storing things like data, config, cache, etc. It works across different platforms (Windows, macOS, Linux), providing a broader scope compared to xdg-basedir which primarily targets XDG standards on Unix-like systems.
appdirs
appdirs is another package that provides similar functionality to xdg-basedir, offering a simple interface to find appropriate platform-specific dirs (like those for data or config). It is also cross-platform and provides more comprehensive support for different operating systems compared to xdg-basedir.
xdg-basedir
Get XDG Base Directory paths
Install
$ npm install --save xdg-basedir
Usage
var xdgBasedir = require('xdg-basedir');
xdgBasedir.data;
xdgBasedir.config;
xdgBasedir.dataDirs
API
.data
Directory for user specific data files.
.config
Directory for user specific configuration files.
.cache
Directory for user specific non-essential data files.
.runtime
Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc).
.dataDirs
Preference-ordered array of base directories to search for data files in addition to .data
.
.configDirs
Preference-ordered array of base directories to search for configuration files in addition to .config
.
License
MIT © Sindre Sorhus