-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9421d8
commit e1b957d
Showing
8 changed files
with
169 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,77 @@ | ||
declare const xdgBasedir: { | ||
/** | ||
Directory for user-specific data files. | ||
@example | ||
```js | ||
import xdgBasedir = require('xdg-basedir'); | ||
xdgBasedir.data; | ||
//=> '/home/sindresorhus/.local/share' | ||
``` | ||
*/ | ||
readonly data?: string; | ||
|
||
/** | ||
Directory for user-specific configuration files. | ||
@example | ||
```js | ||
import xdgBasedir = require('xdg-basedir'); | ||
xdgBasedir.config; | ||
//=> '/home/sindresorhus/.config' | ||
``` | ||
*/ | ||
readonly config?: string; | ||
|
||
/** | ||
Directory for user-specific non-essential data files. | ||
@example | ||
```js | ||
import xdgBasedir = require('xdg-basedir'); | ||
xdgBasedir.cache; | ||
//=> '/home/sindresorhus/.cache' | ||
``` | ||
*/ | ||
readonly cache?: string; | ||
|
||
/** | ||
Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc). | ||
@example | ||
```js | ||
import xdgBasedir = require('xdg-basedir'); | ||
xdgBasedir.runtime; | ||
//=> '/run/user/sindresorhus' | ||
``` | ||
*/ | ||
readonly runtime?: string; | ||
|
||
/** | ||
Preference-ordered array of base directories to search for data files in addition to `.data`. | ||
@example | ||
```js | ||
import xdgBasedir = require('xdg-basedir'); | ||
xdgBasedir.dataDirs | ||
//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/'] | ||
``` | ||
*/ | ||
readonly dataDirs: readonly string[]; | ||
|
||
/** | ||
Preference-ordered array of base directories to search for configuration files in addition to `.config`. | ||
@example | ||
```js | ||
import xdgBasedir = require('xdg-basedir'); | ||
xdgBasedir.configDirs; | ||
//=> ['/home/sindresorhus/.config', '/etc/xdg'] | ||
``` | ||
*/ | ||
readonly configDirs: readonly string[]; | ||
}; | ||
|
||
export = xdgBasedir; | ||
/** | ||
Directory for user-specific data files. | ||
@example | ||
``` | ||
import {xdgData} from 'xdg-basedir'; | ||
console.log(xdgData); | ||
//=> '/home/sindresorhus/.local/share' | ||
``` | ||
*/ | ||
export const xdgData: string | undefined; | ||
|
||
/** | ||
Directory for user-specific configuration files. | ||
@example | ||
``` | ||
import {xdgConfig} from 'xdg-basedir'; | ||
console.log(xdgConfig); | ||
//=> '/home/sindresorhus/.config' | ||
``` | ||
*/ | ||
export const xdgConfig: string | undefined; | ||
|
||
/** | ||
Directory for user-specific non-essential data files. | ||
@example | ||
``` | ||
import {xdgCache} from 'xdg-basedir'; | ||
console.log(xdgCache); | ||
//=> '/home/sindresorhus/.cache' | ||
``` | ||
*/ | ||
export const xdgCache: string | undefined; | ||
|
||
/** | ||
Directory for user-specific non-essential runtime files and other file objects (such as sockets, named pipes, etc). | ||
@example | ||
``` | ||
import {xdgRuntime} from 'xdg-basedir'; | ||
console.log(xdgRuntime); | ||
//=> '/run/user/sindresorhus' | ||
``` | ||
*/ | ||
export const xdgRuntime: string | undefined; | ||
|
||
/** | ||
Preference-ordered array of base directories to search for data files in addition to `xdgData`. | ||
@example | ||
``` | ||
import {xdgDataDirectories} from 'xdg-basedir'; | ||
console.log(xdgDataDirectories); | ||
//=> ['/home/sindresorhus/.local/share', '/usr/local/share/', '/usr/share/'] | ||
``` | ||
*/ | ||
export const xdgDataDirectories: readonly string[]; | ||
|
||
/** | ||
Preference-ordered array of base directories to search for configuration files in addition to `xdgConfig`. | ||
@example | ||
``` | ||
import {xdgConfigDirectories} from 'xdg-basedir'; | ||
console.log(xdgConfigDirectories); | ||
//=> ['/home/sindresorhus/.config', '/etc/xdg'] | ||
``` | ||
*/ | ||
export const xdgConfigDirectories: readonly string[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,27 @@ | ||
'use strict'; | ||
const os = require('os'); | ||
const path = require('path'); | ||
import os from 'os'; | ||
import path from 'path'; | ||
|
||
const homeDirectory = os.homedir(); | ||
const {env} = process; | ||
|
||
exports.data = env.XDG_DATA_HOME || | ||
export const data = env.XDG_DATA_HOME || | ||
(homeDirectory ? path.join(homeDirectory, '.local', 'share') : undefined); | ||
|
||
exports.config = env.XDG_CONFIG_HOME || | ||
export const config = env.XDG_CONFIG_HOME || | ||
(homeDirectory ? path.join(homeDirectory, '.config') : undefined); | ||
|
||
exports.cache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, '.cache') : undefined); | ||
export const cache = env.XDG_CACHE_HOME || (homeDirectory ? path.join(homeDirectory, '.cache') : undefined); | ||
|
||
exports.runtime = env.XDG_RUNTIME_DIR || undefined; | ||
export const runtime = env.XDG_RUNTIME_DIR || undefined; | ||
|
||
exports.dataDirs = (env.XDG_DATA_DIRS || '/usr/local/share/:/usr/share/').split(':'); | ||
export const dataDirs = (env.XDG_DATA_DIRS || '/usr/local/share/:/usr/share/').split(':'); | ||
|
||
if (exports.data) { | ||
exports.dataDirs.unshift(exports.data); | ||
if (data) { | ||
dataDirs.unshift(data); | ||
} | ||
|
||
exports.configDirs = (env.XDG_CONFIG_DIRS || '/etc/xdg').split(':'); | ||
export const configDirs = (env.XDG_CONFIG_DIRS || '/etc/xdg').split(':'); | ||
|
||
if (exports.config) { | ||
exports.configDirs.unshift(exports.config); | ||
if (config) { | ||
configDirs.unshift(config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import {expectType, expectError} from 'tsd'; | ||
import xdgBasedir = require('.'); | ||
import {xdgData, xdgConfig, xdgCache, xdgRuntime, xdgConfigDirectories, xdgDataDirectories} from './index.js'; | ||
|
||
expectType<string | undefined>(xdgBasedir.data); | ||
expectError<string>(xdgBasedir.data); | ||
expectType<string | undefined>(xdgBasedir.config); | ||
expectError<string>(xdgBasedir.config); | ||
expectType<string | undefined>(xdgBasedir.cache); | ||
expectError<string>(xdgBasedir.cache); | ||
expectType<string | undefined>(xdgBasedir.runtime); | ||
expectError<string>(xdgBasedir.runtime); | ||
expectType<readonly string[]>(xdgBasedir.configDirs); | ||
expectError<string[]>(xdgBasedir.configDirs); | ||
expectType<readonly string[]>(xdgBasedir.dataDirs); | ||
expectError<string[]>(xdgBasedir.dataDirs); | ||
expectType<string | undefined>(xdgData); | ||
expectError<string>(xdgData); | ||
expectType<string | undefined>(xdgCache); | ||
expectError<string>(xdgCache); | ||
expectType<string | undefined>(xdgCache); | ||
expectError<string>(xdgCache); | ||
expectType<string | undefined>(xdgRuntime); | ||
expectError<string>(xdgRuntime); | ||
expectType<readonly string[]>(xdgConfigDirectories); | ||
expectError<string[]>(xdgConfigDirectories); | ||
expectType<readonly string[]>(xdgDataDirectories); | ||
expectError<string[]>(xdgDataDirectories); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com) | ||
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,16 @@ | |
"description": "Get XDG Base Directory paths", | ||
"license": "MIT", | ||
"repository": "sindresorhus/xdg-basedir", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=12" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
|
@@ -37,5 +40,8 @@ | |
"import-fresh": "^3.0.0", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
}, | ||
"ava": { | ||
"serial": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.