|
1 | | -declare namespace envPaths { |
2 | | - export interface Options { |
3 | | - /** |
4 | | - __Don't use this option unless you really have to!__ |
| 1 | +export interface Options { |
| 2 | + /** |
| 3 | + __Don't use this option unless you really have to!__ |
5 | 4 |
|
6 | | - Suffix appended to the project name to avoid name conflicts with native apps. Pass an empty string to disable it. |
| 5 | + Suffix appended to the project name to avoid name conflicts with native apps. Pass an empty string to disable it. |
7 | 6 |
|
8 | | - @default 'nodejs' |
9 | | - */ |
10 | | - readonly suffix?: string; |
11 | | - } |
| 7 | + @default 'nodejs' |
| 8 | + */ |
| 9 | + readonly suffix?: string; |
| 10 | +} |
12 | 11 |
|
13 | | - export interface Paths { |
14 | | - /** |
15 | | - Directory for data files. |
| 12 | +export interface Paths { |
| 13 | + /** |
| 14 | + Directory for data files. |
16 | 15 |
|
17 | | - Example locations (with the default `nodejs` suffix): |
| 16 | + Example locations (with the default `nodejs` suffix): |
18 | 17 |
|
19 | | - - macOS: `~/Library/Application Support/MyApp-nodejs` |
20 | | - - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Data` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Data`) |
21 | | - - Linux: `~/.local/share/MyApp-nodejs` (or `$XDG_DATA_HOME/MyApp-nodejs`) |
22 | | - */ |
23 | | - readonly data: string; |
| 18 | + - macOS: `~/Library/Application Support/MyApp-nodejs` |
| 19 | + - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Data` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Data`) |
| 20 | + - Linux: `~/.local/share/MyApp-nodejs` (or `$XDG_DATA_HOME/MyApp-nodejs`) |
| 21 | + */ |
| 22 | + readonly data: string; |
24 | 23 |
|
25 | | - /** |
26 | | - Directory for data files. |
| 24 | + /** |
| 25 | + Directory for data files. |
27 | 26 |
|
28 | | - Example locations (with the default `nodejs` suffix): |
| 27 | + Example locations (with the default `nodejs` suffix): |
29 | 28 |
|
30 | | - - macOS: `~/Library/Preferences/MyApp-nodejs` |
31 | | - - Windows: `%APPDATA%\MyApp-nodejs\Config` (for example, `C:\Users\USERNAME\AppData\Roaming\MyApp-nodejs\Config`) |
32 | | - - Linux: `~/.config/MyApp-nodejs` (or `$XDG_CONFIG_HOME/MyApp-nodejs`) |
33 | | - */ |
34 | | - readonly config: string; |
| 29 | + - macOS: `~/Library/Preferences/MyApp-nodejs` |
| 30 | + - Windows: `%APPDATA%\MyApp-nodejs\Config` (for example, `C:\Users\USERNAME\AppData\Roaming\MyApp-nodejs\Config`) |
| 31 | + - Linux: `~/.config/MyApp-nodejs` (or `$XDG_CONFIG_HOME/MyApp-nodejs`) |
| 32 | + */ |
| 33 | + readonly config: string; |
35 | 34 |
|
36 | | - /** |
37 | | - Directory for non-essential data files. |
| 35 | + /** |
| 36 | + Directory for non-essential data files. |
38 | 37 |
|
39 | | - Example locations (with the default `nodejs` suffix): |
| 38 | + Example locations (with the default `nodejs` suffix): |
40 | 39 |
|
41 | | - - macOS: `~/Library/Caches/MyApp-nodejs` |
42 | | - - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Cache` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Cache`) |
43 | | - - Linux: `~/.cache/MyApp-nodejs` (or `$XDG_CACHE_HOME/MyApp-nodejs`) |
44 | | - */ |
45 | | - readonly cache: string; |
| 40 | + - macOS: `~/Library/Caches/MyApp-nodejs` |
| 41 | + - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Cache` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Cache`) |
| 42 | + - Linux: `~/.cache/MyApp-nodejs` (or `$XDG_CACHE_HOME/MyApp-nodejs`) |
| 43 | + */ |
| 44 | + readonly cache: string; |
46 | 45 |
|
47 | | - /** |
48 | | - Directory for log files. |
| 46 | + /** |
| 47 | + Directory for log files. |
49 | 48 |
|
50 | | - Example locations (with the default `nodejs` suffix): |
| 49 | + Example locations (with the default `nodejs` suffix): |
51 | 50 |
|
52 | | - - macOS: `~/Library/Logs/MyApp-nodejs` |
53 | | - - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Log` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Log`) |
54 | | - - Linux: `~/.local/state/MyApp-nodejs` (or `$XDG_STATE_HOME/MyApp-nodejs`) |
55 | | - */ |
56 | | - readonly log: string; |
| 51 | + - macOS: `~/Library/Logs/MyApp-nodejs` |
| 52 | + - Windows: `%LOCALAPPDATA%\MyApp-nodejs\Log` (for example, `C:\Users\USERNAME\AppData\Local\MyApp-nodejs\Log`) |
| 53 | + - Linux: `~/.local/state/MyApp-nodejs` (or `$XDG_STATE_HOME/MyApp-nodejs`) |
| 54 | + */ |
| 55 | + readonly log: string; |
57 | 56 |
|
58 | | - /** |
59 | | - Directory for temporary files. |
| 57 | + /** |
| 58 | + Directory for temporary files. |
60 | 59 |
|
61 | | - Example locations (with the default `nodejs` suffix): |
| 60 | + Example locations (with the default `nodejs` suffix): |
62 | 61 |
|
63 | | - - macOS: `/var/folders/jf/f2twvvvs5jl_m49tf034ffpw0000gn/T/MyApp-nodejs` |
64 | | - - Windows: `%LOCALAPPDATA%\Temp\MyApp-nodejs` (for example, `C:\Users\USERNAME\AppData\Local\Temp\MyApp-nodejs`) |
65 | | - - Linux: `/tmp/USERNAME/MyApp-nodejs` |
66 | | - */ |
67 | | - readonly temp: string; |
68 | | - } |
| 62 | + - macOS: `/var/folders/jf/f2twvvvs5jl_m49tf034ffpw0000gn/T/MyApp-nodejs` |
| 63 | + - Windows: `%LOCALAPPDATA%\Temp\MyApp-nodejs` (for example, `C:\Users\USERNAME\AppData\Local\Temp\MyApp-nodejs`) |
| 64 | + - Linux: `/tmp/USERNAME/MyApp-nodejs` |
| 65 | + */ |
| 66 | + readonly temp: string; |
69 | 67 | } |
70 | 68 |
|
71 | | -declare const envPaths: { |
72 | | - /** |
73 | | - Get paths for storing things like data, config, cache, etc. |
74 | | -
|
75 | | - Note: It only generates the path strings. It doesn't create the directories for you. You could use [`make-dir`](https://github.com/sindresorhus/make-dir) to create the directories. |
| 69 | +/** |
| 70 | +Get paths for storing things like data, config, cache, etc. |
76 | 71 |
|
77 | | - @param name - Name of your project. Used to generate the paths. |
78 | | - @returns The paths to use for your project on current OS. |
| 72 | +Note: It only generates the path strings. It doesn't create the directories for you. You could use [`make-dir`](https://github.com/sindresorhus/make-dir) to create the directories. |
79 | 73 |
|
80 | | - @example |
81 | | - ``` |
82 | | - import envPaths = require('env-paths'); |
| 74 | +@param name - The name of your project. Used to generate the paths. |
| 75 | +@returns The paths to use for your project on current OS. |
83 | 76 |
|
84 | | - const paths = envPaths('MyApp'); |
| 77 | +@example |
| 78 | +``` |
| 79 | +import envPaths from 'env-paths'; |
85 | 80 |
|
86 | | - paths.data; |
87 | | - //=> '/home/sindresorhus/.local/share/MyApp-nodejs' |
88 | | -
|
89 | | - paths.config |
90 | | - //=> '/home/sindresorhus/.config/MyApp-nodejs' |
91 | | - ``` |
92 | | - */ |
93 | | - (name: string, options?: envPaths.Options): envPaths.Paths; |
| 81 | +const paths = envPaths('MyApp'); |
94 | 82 |
|
95 | | - // TODO: Remove this for the next major release, refactor the whole definition to: |
96 | | - // declare function envPaths(name: string, options?: envPaths.Options): envPaths.Paths; |
97 | | - // export = envPaths; |
98 | | - default: typeof envPaths; |
99 | | -}; |
| 83 | +paths.data; |
| 84 | +//=> '/home/sindresorhus/.local/share/MyApp-nodejs' |
100 | 85 |
|
101 | | -export = envPaths; |
| 86 | +paths.config |
| 87 | +//=> '/home/sindresorhus/.config/MyApp-nodejs' |
| 88 | +``` |
| 89 | +*/ |
| 90 | +export default function envPaths(name: string, options?: Options): Paths; |
0 commit comments