os-user-dirs 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/index.d.ts +17 -0
- package/index.js +58 -0
- package/index.mjs +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -165,6 +165,15 @@ Returns the path to the Public Share directory.
|
|
|
165
165
|
### `getPath(name)`
|
|
166
166
|
Returns the path to the specified user directory. Valid names: `desktop`, `downloads`, `documents`, `music`, `pictures`, `videos`, `templates`, `publicshare`.
|
|
167
167
|
|
|
168
|
+
### `binDir()`
|
|
169
|
+
Returns the path to the user local bin directory (`~/.local/bin` on Linux/macOS), or `null` on Windows.
|
|
170
|
+
|
|
171
|
+
### `applicationsDir()`
|
|
172
|
+
Returns the path to the user applications directory.
|
|
173
|
+
- Linux: `$XDG_DATA_HOME/applications` (default `~/.local/share/applications`)
|
|
174
|
+
- macOS: `~/Applications`
|
|
175
|
+
- Windows: `%APPDATA%\Microsoft\Windows\Start Menu\Programs`
|
|
176
|
+
|
|
168
177
|
### Base Directories
|
|
169
178
|
|
|
170
179
|
#### `configDir()`
|
|
@@ -185,6 +194,9 @@ Returns the path to the log directory (`~/.local/state` on Linux, `~/Library/Log
|
|
|
185
194
|
#### `runtimeDir()`
|
|
186
195
|
Returns the path to the runtime directory (`$XDG_RUNTIME_DIR` on Linux), or `null` if unavailable.
|
|
187
196
|
|
|
197
|
+
#### `fontsDir()`
|
|
198
|
+
Returns the path to the user fonts directory (`~/.local/share/fonts` on Linux, `~/Library/Fonts` on macOS, `%LOCALAPPDATA%/Microsoft/Windows/Fonts` on Windows). On Linux, respects `$XDG_DATA_HOME`.
|
|
199
|
+
|
|
188
200
|
#### `getBasePath(name)`
|
|
189
201
|
Returns the path to the specified base directory. Valid names: `config`, `data`, `cache`, `state`, `log`, `runtime`.
|
|
190
202
|
|
package/index.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export function publicshare(): string;
|
|
|
27
27
|
/** Returns the path to the specified user directory. */
|
|
28
28
|
export function getPath(name: DirName): string;
|
|
29
29
|
|
|
30
|
+
/** Returns the path to the user local bin directory (~/.local/bin), or null on Windows. */
|
|
31
|
+
export function binDir(): string | null;
|
|
32
|
+
|
|
30
33
|
type BaseDirName = "config" | "data" | "cache" | "state" | "log" | "runtime";
|
|
31
34
|
|
|
32
35
|
/** Returns the path to the XDG config directory. */
|
|
@@ -47,6 +50,9 @@ export function logDir(): string;
|
|
|
47
50
|
/** Returns the path to the XDG runtime directory, or null if unavailable. */
|
|
48
51
|
export function runtimeDir(): string | null;
|
|
49
52
|
|
|
53
|
+
/** Returns the path to the user fonts directory. */
|
|
54
|
+
export function fontsDir(): string;
|
|
55
|
+
|
|
50
56
|
/**
|
|
51
57
|
* Returns the system config directory search path list.
|
|
52
58
|
* On Linux, reads `$XDG_CONFIG_DIRS` (default: `["/etc/xdg"]`).
|
|
@@ -94,6 +100,14 @@ interface ProjectDirsResult {
|
|
|
94
100
|
*/
|
|
95
101
|
export function projectDirs(name: string, options?: ProjectDirsOptions): ProjectDirsResult;
|
|
96
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Returns the path to the user applications directory.
|
|
105
|
+
* Linux: `$XDG_DATA_HOME/applications` (default `~/.local/share/applications`)
|
|
106
|
+
* macOS: `~/Applications`
|
|
107
|
+
* Windows: `%APPDATA%/Microsoft/Windows/Start Menu/Programs`
|
|
108
|
+
*/
|
|
109
|
+
export function applicationsDir(): string;
|
|
110
|
+
|
|
97
111
|
/**
|
|
98
112
|
* Reads an XDG user-dirs.dirs config and returns the directory for the given key.
|
|
99
113
|
* @param key - XDG key (e.g. "XDG_DOWNLOAD_DIR")
|
|
@@ -117,16 +131,19 @@ declare const osUserDirs: typeof downloads & {
|
|
|
117
131
|
templates: typeof templates;
|
|
118
132
|
publicshare: typeof publicshare;
|
|
119
133
|
getPath: typeof getPath;
|
|
134
|
+
binDir: typeof binDir;
|
|
120
135
|
configDir: typeof configDir;
|
|
121
136
|
dataDir: typeof dataDir;
|
|
122
137
|
cacheDir: typeof cacheDir;
|
|
123
138
|
stateDir: typeof stateDir;
|
|
124
139
|
logDir: typeof logDir;
|
|
125
140
|
runtimeDir: typeof runtimeDir;
|
|
141
|
+
fontsDir: typeof fontsDir;
|
|
126
142
|
getBasePath: typeof getBasePath;
|
|
127
143
|
configDirs: typeof configDirs;
|
|
128
144
|
dataDirs: typeof dataDirs;
|
|
129
145
|
projectDirs: typeof projectDirs;
|
|
146
|
+
applicationsDir: typeof applicationsDir;
|
|
130
147
|
getXDGUserDir: typeof getXDGUserDir;
|
|
131
148
|
getXDGDownloadDir: typeof getXDGDownloadDir;
|
|
132
149
|
};
|
package/index.js
CHANGED
|
@@ -137,6 +137,13 @@ function resolveBase(name) {
|
|
|
137
137
|
return cfg.linux ? path.join(homedir, cfg.linux) : null;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
function binDir() {
|
|
141
|
+
if (process.platform === "win32") {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
return path.join(os.homedir(), ".local", "bin");
|
|
145
|
+
}
|
|
146
|
+
|
|
140
147
|
function configDir() { return resolveBase("config"); }
|
|
141
148
|
function dataDir() { return resolveBase("data"); }
|
|
142
149
|
function cacheDir() { return resolveBase("cache"); }
|
|
@@ -144,6 +151,31 @@ function stateDir() { return resolveBase("state"); }
|
|
|
144
151
|
function logDir() { return resolveBase("log"); }
|
|
145
152
|
function runtimeDir() { return resolveBase("runtime"); }
|
|
146
153
|
|
|
154
|
+
function fontsDir() {
|
|
155
|
+
var platform = process.platform;
|
|
156
|
+
var homedir = os.homedir();
|
|
157
|
+
|
|
158
|
+
if (platform === "linux") {
|
|
159
|
+
var envVal = process.env.XDG_DATA_HOME;
|
|
160
|
+
if (envVal) {
|
|
161
|
+
return path.join(path.resolve(envVal), "fonts");
|
|
162
|
+
}
|
|
163
|
+
return path.join(homedir, ".local", "share", "fonts");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (platform === "darwin") {
|
|
167
|
+
return path.join(homedir, "Library", "Fonts");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (platform === "win32") {
|
|
171
|
+
var localAppData = process.env.LOCALAPPDATA || path.join(homedir, "AppData", "Local");
|
|
172
|
+
return path.join(localAppData, "Microsoft", "Windows", "Fonts");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Unknown platform: use XDG-style default
|
|
176
|
+
return path.join(homedir, ".local", "share", "fonts");
|
|
177
|
+
}
|
|
178
|
+
|
|
147
179
|
const SEARCH_DIRS_CONFIG = {
|
|
148
180
|
config: {
|
|
149
181
|
env: "XDG_CONFIG_DIRS",
|
|
@@ -261,6 +293,29 @@ function projectDirs(name, options) {
|
|
|
261
293
|
};
|
|
262
294
|
}
|
|
263
295
|
|
|
296
|
+
function applicationsDir() {
|
|
297
|
+
var homedir = os.homedir();
|
|
298
|
+
var platform = process.platform;
|
|
299
|
+
|
|
300
|
+
if (platform === "linux") {
|
|
301
|
+
var envVal = process.env.XDG_DATA_HOME;
|
|
302
|
+
var base = envVal ? path.resolve(envVal) : path.join(homedir, ".local", "share");
|
|
303
|
+
return path.join(base, "applications");
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (platform === "darwin") {
|
|
307
|
+
return path.join(homedir, "Applications");
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (platform === "win32") {
|
|
311
|
+
var appdata = process.env.APPDATA || path.join(homedir, "AppData", "Roaming");
|
|
312
|
+
return path.join(appdata, "Microsoft", "Windows", "Start Menu", "Programs");
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Unknown platform: use XDG-style default
|
|
316
|
+
return path.join(homedir, ".local", "share", "applications");
|
|
317
|
+
}
|
|
318
|
+
|
|
264
319
|
// Backward compatibility: require("os-user-dirs")() returns Downloads path
|
|
265
320
|
module.exports = downloads;
|
|
266
321
|
module.exports.getPath = getPath;
|
|
@@ -272,16 +327,19 @@ module.exports.pictures = pictures;
|
|
|
272
327
|
module.exports.videos = videos;
|
|
273
328
|
module.exports.templates = templates;
|
|
274
329
|
module.exports.publicshare = publicshare;
|
|
330
|
+
module.exports.binDir = binDir;
|
|
275
331
|
module.exports.configDir = configDir;
|
|
276
332
|
module.exports.dataDir = dataDir;
|
|
277
333
|
module.exports.cacheDir = cacheDir;
|
|
278
334
|
module.exports.stateDir = stateDir;
|
|
279
335
|
module.exports.logDir = logDir;
|
|
280
336
|
module.exports.runtimeDir = runtimeDir;
|
|
337
|
+
module.exports.fontsDir = fontsDir;
|
|
281
338
|
module.exports.getBasePath = getBasePath;
|
|
282
339
|
module.exports.configDirs = configDirs;
|
|
283
340
|
module.exports.dataDirs = dataDirs;
|
|
284
341
|
module.exports.projectDirs = projectDirs;
|
|
342
|
+
module.exports.applicationsDir = applicationsDir;
|
|
285
343
|
module.exports.getXDGUserDir = getXDGUserDir;
|
|
286
344
|
|
|
287
345
|
// Deprecated: kept for backward compatibility
|
package/index.mjs
CHANGED
|
@@ -10,15 +10,18 @@ export const videos = osUserDirs.videos;
|
|
|
10
10
|
export const templates = osUserDirs.templates;
|
|
11
11
|
export const publicshare = osUserDirs.publicshare;
|
|
12
12
|
export const getPath = osUserDirs.getPath;
|
|
13
|
+
export const binDir = osUserDirs.binDir;
|
|
13
14
|
export const configDir = osUserDirs.configDir;
|
|
14
15
|
export const dataDir = osUserDirs.dataDir;
|
|
15
16
|
export const cacheDir = osUserDirs.cacheDir;
|
|
16
17
|
export const stateDir = osUserDirs.stateDir;
|
|
17
18
|
export const logDir = osUserDirs.logDir;
|
|
18
19
|
export const runtimeDir = osUserDirs.runtimeDir;
|
|
20
|
+
export const fontsDir = osUserDirs.fontsDir;
|
|
19
21
|
export const getBasePath = osUserDirs.getBasePath;
|
|
20
22
|
export const configDirs = osUserDirs.configDirs;
|
|
21
23
|
export const dataDirs = osUserDirs.dataDirs;
|
|
22
24
|
export const projectDirs = osUserDirs.projectDirs;
|
|
25
|
+
export const applicationsDir = osUserDirs.applicationsDir;
|
|
23
26
|
export const getXDGUserDir = osUserDirs.getXDGUserDir;
|
|
24
27
|
export const getXDGDownloadDir = osUserDirs.getXDGDownloadDir;
|
package/package.json
CHANGED