New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

appdirectory

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appdirectory

A cross-platform utility to find the best directory to put data and config files.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
114K
decreased by-9.11%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status Coverage Status

AppDirectory

AppDirectory is a port of Python's appdirs module. It can be used as a small cross-platform tool to find the correct directory for an application to use for persistence. It isn't perfect, but it might be useful.

Usage

AppDirectory offers one export: the AppDirectory constructor:

var AppDirectory = require('appdirectory')
var dirs = new AppDirectory('mycoolappname')

AppDirectory can be instantiated either with a single string (the application's name) or an object containing more information about the application.

var dirs = new AppDirectory({
    appName: "mycoolapp", // the app's name, kinda self-explanatory
    appAuthor: "Superman", // The author's name, or (more likely) the name of the company/organisation producing this software.
                           // Only used on Windows, if omitted will default to appName.
    appVersion: "v6000", // The version, will be appended to certain dirs to allow for distinction between versions.
                         // If it isn't present, no version parameter will appear in the paths
    useRoaming: true, // Should AppDirectory use Window's roaming directories?  (Defaults to false)
    platform: "darwin" // You should almost never need to use this, it will be automatically determined
})

Now to get some actual paths.

dirs.userData() // e.g. /home/awesomeuser/Library/Application Support/mycoolapp on Macs
dirs.userConfig() // e.g. /home/awesomeuser/.config/mycoolapp on linux etc.
dirs.userCache() // e.g. C:\Users\awesomeuser\AppData\Local\mycoolapp\mycoolapp\Cache on Windows 7 (and Vista, I believe)
dirs.userLogs() // e.g. /home/awesomeuser/.cache/mycoolapp/log

That's pretty much all there is to it.

Todo

  • Fix site* functions
  • npm

Known Limitations

  • On Windows Vista, the site-config and site-data directories are hidden system directories, which may cause issues. I don't have a copy of Vista to hand to play around with how well this works, though, so YMMV.
  • On unix-likes (including those with XDG-compliance), requesting the site-config and site-data directories will return just one directory, even in cases where the XDG* variables contain more than one individual path. (Specifically, it will be the first path AppDirectory finds.)

Keywords

FAQs

Package last updated on 11 Mar 2014

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