0.1.0 • Published 10 years ago

appdirectory v0.1.0

Weekly downloads
87,064
License
MIT
Repository
-
Last release
10 years ago

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
  • Test all user* functions

Known Limitations

Note: All this limitations have been fixed by virtue of removing the site* functions. The aim is to add them back in, at which point they will still exist, as one's a design decision, and the other's unfixable as far as I can tell. However, at this point, there are no known limitations to AppDirectory! (Feel free to tell me about new limitations by filing an issue.)

  • 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.)
@tf2autobot/node-steam-tradeoffer-manager@everything-registry/sub-chunk-1156homebridge-xiaomi-devicesdesktop-dimmerelectron-pluginselectron-updater-sqlseerelectron-updater-toolsele-updaterddc-serverless-python-requirementsdatomish-user-agent-service@fuomag9/miiokoteky@gen-codes/clihomebridge-mi-waterpurihplayertrade-opskins-managerts_steam_userjslinkeryt-playlist-heroyt-playlist-prohomebridge-aqara-hub-lux@indexyz/miionarou-cli@malagu/python-plugin@innomizetech/serverless-python-requirements@gemerz/miioyoutube-playlist-player@hardyscc/serverless-python-requirements@kimsehwan96/serverless-python-requirements@kschwab/serverless-python-requirementsmiio-yeelight22miio_qingpingmiiormiiomiio-fix-v7miio-nicoh88miio-yeelight-xmijiamijia-io@hoobs/miiolive-wallpaper-ecorp@rifat/miiopb-for-desktopnodemacros@dust2market/steam-user@dust2market/steam-tradeoffer-manager@felipejfc/mijia-io@nrchkb/miio@nrchkb/mijia-io@nodeswork/namoanda-stats@pajn/miio@oneblink/cli@rtweeks/serverless-python-requirements@zpmpkg/zpm@zalastax/nolb-appdserverless-python-requirementsserverless-python-requirements-bw@blinkmobile/blinkmrc@vgm-com/steam-tradeoffer-manager@abquintic/electron-pluginsrpncalc@yugasun/python-requirements@wisp-gg/steam-user@svyatogor/miio-yeelight-x@sidneys/logger@sidneys/logger-v2@slsplus/python-requirements@ajk8/serverless-python-requirementsabstract-things@cardano-graphql/cli@clowdhaus/serverless-python-requirementssteam-gameserverbosco-altbosco-coresteam-user-fitchersteamstuffsql-seer@datagica/local-settingscardano-graphql-clitaskcluster-clitinkerhubd
0.1.0

10 years ago

0.0.1

10 years ago