Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appdirsjs

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appdirsjs

OS-dependent application paths for cache, data and config directories

  • 1.2.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
increased by4.82%
Maintainers
1
Weekly downloads
 
Created
Source

appdirsjs

GitHub Workflow Status Codecov npm npm bundle size GitHub

A node.js library to get paths to directories to store configs, caches and data according to OS standarts.

Installation

npm install appdirsjs

or

yarn install appdirsjs

if you're using yarn.

Usage

import appDirs from "appdirsjs";

const dirs = appDirs({ appName: "expo" });

console.log(dirs.cache);
// /home/user/.cache/expo on Linux
// /Users/User/Library/Caches/expo on MacOS
// C:\Users\User\AppData\Local\Temp\expo on Windows

console.log(dirs.config);
// /home/user/.config/expo on Linux
// /Users/User/Library/Preferences/expo on MacOS
// C:\Users\User\AppData\Roaming\expo

console.log(dirs.data);
// /home/user/.local/share/expo on Linux
// /Users/User/Library/Application Support/expo on MacOS
// C:\Users\User\AppData\Local\expo

Keep backward compability

Then switching from old-style dotfile directory, such as ~/.myapp to new, like ~/.config/myapp, you can pass legacyPath parameter to keep using old directory if it exists:

import * as path from "path";
import appDirs from "appdirsjs";

const dirs = appDirs({
  appName: "expo",
  // Notice usage of full path
  legacyPath: path.join(os.homedir(), ".expo"),
});

console.log(dirs.config);
// /home/user/.expo

TODO

  • Android support
  • XDG on BSD support

FAQs

Package last updated on 08 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc