GithubHelp home page GithubHelp logo

appdata-path's Introduction

AppData Path

Installation

npm install -S appdata-path

Usage

import getAppDataPath from "appdata-path";
// Or
// const getAppDataPath = require("appdata-path");

console.log(getAppDataPath());
/*
 * Linux:
 * "/home/demurgos/.config"
 * 
 * Mac:
 * "/Users/demurgos/Library/Application Support"
 * 
 * Windows:
 * "C:\Users\demurgos\AppData\Roaming"
 * 
 * System with custom `APPDATA` environment variable:
 * process.env["APPDATA"]
 * For example:
 * process.env["APPDATA"] = "/home/demurgos/apps"
 * => "/home/demurgos/apps"
 */

console.log(getAppDataPath("my-app"));
/*
 * Linux:
 * "/home/demurgos/.config/my-app"
 * 
 * Mac:
 * "/Users/demurgos/Library/Application Support/my-app"
 * 
 * Windows:
 * "C:\Users\demurgos\AppData\Roaming\my-app"
 * 
 * System with custom `APPDATA` environment variable:
 * path.join(process.env["APPDATA"], "my-app")
 * or (if `process.env["APPDATA"] === os.homedir()`)
 * path.join(process.env["APPDATA"], ".my-app")
 * For example:
 * process.env["APPDATA"] = "/home/demurgos/apps"
 * => "/home/demurgos/apps/my-app"
 * process.env["APPDATA"] = "/home/demurgos"
 * => "/home/demurgos/.my-app"
 */

API

getAppDataPath(app?: string): string

Returns the absolute system-dependant path for the place where applications should store their data for the current user. If you pass the name of your app directory or file as an argument, it will return the absolute path for the place where you should store the data of your application. It will prefix you file / directory name by a dot if the AppData directory happens to also be the user's home, otherwise it will just use it as is. See the examples above.

Changelog

See CHANGELOG.md.

License

See LICENSE.md.

appdata-path's People

Contributors

demurgos 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.