https://github.com/xan105/node-usershellfolder
User shell folders
https://github.com/xan105/node-usershellfolder
folder node registry xdg
Last synced: 8 months ago
JSON representation
User shell folders
- Host: GitHub
- URL: https://github.com/xan105/node-usershellfolder
- Owner: xan105
- License: mit
- Created: 2021-05-11T16:13:35.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-23T04:45:13.000Z (over 1 year ago)
- Last Synced: 2024-05-02T05:20:21.170Z (over 1 year ago)
- Topics: folder, node, registry, xdg
- Language: JavaScript
- Homepage:
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
About
=====User shell folders.
Example
=======```js
import { folders } from "@xan105/usershellfolder";const path = folders.user.desktop;
console.log(path);
//Win: C:\Users\Xan\Desktop
//Linux: /home/Xan/Desktop
```Install
=======```
npm install @xan105/usershellfolder
```API
===⚠️ This module is only available as an ECMAScript module (ESM).
## Named export
### `const folders = object`
#### Windows
On Windows return an object as the following:
```js
{
root: ...,
temp: ...,
user: {
appData: ...,
localAppData: ...,
home: ...,
desktop: ...,
documents: ...,
music: ...,
pictures: ...,
videos: ...,
download: ...,
savegame: ...
},
common: {
appData: ...,
home: ...,
desktop: ...,
documents: ...,
music: ...,
pictures: ...,
videos: ...
}
}
```#### Linux
On Linux return an object as the following:
```js
{
root: ...,
temp: ...,
user: {
data: ...,
config: ...,
cache: ...,
home: ...,
desktop: ...,
documents: ...,
music: ...,
pictures: ...,
videos: ...,
download: ...
}
}
```### `expand(string: string, map?: object = process.env) string`
Expand replaces `%VAR%` in the string based on the mapping object.
If no mapping object is provided then it uses `process.env`.Example:
```js
import { expand, folders } from "@xan105/usershellfolder";expand("%DOCUMENTS%", folders.user); //C:\\Users\\Xan\\Documents
expand("%APPDATA%"); //C:\\Users\\Xan\\AppDataexpand("%USER%", { USER: "foo" }) //foo
expand("%USER%", { user: "foo" }) //fooexpand("%USER%", { FOO: "bar" }) //%USER%
```## Default export
Alias to `const folders` for backward compatibility