Giter Site home page Giter Site logo

basedirs's Introduction

basedirs

Get base directory paths appropriate to your OS.

Specs

Precedent

Usage

cachedir

cachedir(): string | null
cachedir(appName: string): string | null

Returns the path for user-specific non-essential (cached) data. Examples include servers with cached response data or applications using ephemeral data retrieved from the internet.

If appName is given, a path specifically for that app is returned.

If called on an unsupported platform, null is returned.

import { cachedir } from 'basedirs'

console.log(cachedir()) // `$HOME/.cache`, `$HOME/Library/Caches`, or `%LOCALAPPDATA%`
console.log(cachedir('App Name')) // `$HOME/.cache/app-name`, `$HOME/Library/Caches/App Name`, or `%LOCALAPPDATA%\App Name\Cache`

configdir

configdir(): string | null
configdir(appName: string): string | null

Returns the path for user-specific configuration files. Examples include application preferences or settings for CLI apps.

If appName is given, a path specifically for that app is returned.

If called on an unsupported platform, null is returned.

import { configdir } from 'basedirs'

console.log(configdir()) // `$HOME/.config`, `$HOME/Library/Preferences`, or `%APPDATA%`
console.log(configdir('App Name')) // `$HOME/.config/app-name`, `$HOME/Library/Preferences/App Name`, or `%APPDATA%\App Name\Config`

configdirs

configdirs(): string[] | null

Returns the paths for non-user-specific configuration files.

If called on an unsupported platform, null is returned.

import { configdirs } from 'basedirs'

console.log(configdirs()) // `['/etc/xdg']`, `['/Library/Preferences']`, or `['%ALLUSERSPROFILE%']`

datadir

datadir(): string | null
datadir(appName: string): string | null

Returns the path for user-specific data files. Examples include saved game files, mail client databases, or chat client log storage.

If appName is given, a path specifically for that app is returned.

If called on an unsupported platform, null is returned.

import { datadir } from 'basedirs'

console.log(datadir()) // `$HOME/.local/share`, `$HOME/Library/Application Support`, or `%APPDATA%`
console.log(datadir('App Name')) // `$HOME/.local/share/app-name`, `$HOME/Library/Application Support/App Name`, or `%APPDATA%\App Name\Data`

datadirs

datadirs(): string | null

Returns the paths for non-user-specific data files.

If called on an unsupported platform, null is returned.

import { datadirs } from 'basedirs'

console.log(datadirs()) // `['/usr/local/share', '/usr/share']`, `['/Library/Application Support']`, or `['%ALLUSERSPROFILE%']`

datalocaldir

datalocaldir(): string | null
datalocaldir(appName: string): string | null

Returns the path for user-specific data files that will preferably not be transferred to other machines with the same user account.

If appName is given, a path specifically for that app is returned.

If called on an unsupported platform, null is returned.

import { datalocaldir } from 'basedirs'

console.log(datalocaldir()) // `$HOME/.local/share`, `$HOME/Library/Application Support`, or `%LOCALAPPDATA%`
console.log(datalocaldir('App Name')) // `$HOME/.local/share/app-name`, `$HOME/Library/Application Support/App Name`, or `%LOCALAPPDATA%\App Name\Data`

executabledir

executabledir(): string | null

Returns the path for user-specific executable files.

If called on an unsupported platform, null is returned.

import { executabledir } from 'basedirs'

console.log(executabledir()) // `$HOME/.local/bin`, `$HOME/Applications`, or `%LOCALAPPDATA%\Programs`

homedir

homedir(): string | null

Returns the path for user files in general.

If called on an unsupported platform, null is returned.

import { homedir } from 'basedirs'

console.log(homedir()) // `$HOME` or `%USERPROFILE%`

runtimedir

runtimedir(): string | null

Returns the path for user-specific runtime files and file objects. This includes sockets and named pipes, but not other temporary files.

Only supported on Linux. If called on an unsupported platform, null is returned. May sometimes return null even on Linux.

import { runtimedir } from 'basedirs'

console.log(runtimedir()) // depends on the specifics of the Linux system

basedirs's People

Contributors

dependabot[bot] avatar icopp avatar semantic-release-bot avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.