Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nativecode-dev/common-locations
Node module that provides access to common locations across platforms.
https://github.com/nativecode-dev/common-locations
common-locations config configuration darwin etc linux locations node windows
Last synced: 19 days ago
JSON representation
Node module that provides access to common locations across platforms.
- Host: GitHub
- URL: https://github.com/nativecode-dev/common-locations
- Owner: nativecode-dev
- License: mit
- Created: 2017-02-09T13:19:51.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-30T22:35:45.000Z (over 7 years ago)
- Last Synced: 2024-12-14T04:37:13.503Z (2 months ago)
- Topics: common-locations, config, configuration, darwin, etc, linux, locations, node, windows
- Language: JavaScript
- Homepage:
- Size: 78.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# common-locations
[](https://www.npmjs.com/package/common-locations)
[](https://travis-ci.org/nativecode-dev/common-locations)
[](https://build.nativecode.com/viewType.html?buildTypeId=commonlocations_continuous&guest=1)
[](https://www.npmjs.com/package/common-locations)
[](https://www.npmjs.com/package/common-locations)Node module that provides access to common locations across platforms.
# Installation
```
npm install --save common-locations
```# Usage
The default usage of the library can be invoked by just requiring the package
and passing the name of your application.
```javascript
const cl = require('common-locations')
const locations = cl('myapp')
```If you wish to use with [memfs](https://www.npmjs.com/package/memfs) or
[unionfs](https://www.npmjs.com/package/unionfs), you can optionally pass in an
`fs` object.
```javascript
const fs = require('fs')
const cl = require('common-locations')
const locations = cl.use('myapp', fs)
```You can also pass in an `env` object as well, that is merged with the `process.env`
variables.
```javascript
const locations = cl.use('myapp', fs, {
NODE_ENV: 'debug'
})
```NOTE: It will mainly affect Windows as most of the directory locations are pulled
from environment variables.Once you've required the module, you can access the various methods in the namespace.
```javascript
const home = locations.home()
```The above will return `/home/` on POSIX systems or `C:\Users\` on
Windows machines. You can optionally pass additional directory parts as well.
```javascript
const home = locations.home('etc', 'myapp')
```The above will return `/home//etc/myapp`.
NOTE: You will have to view the source to see the other options until the API is finalized
and documentation is produced.- app
- local()
- system()
- user()
- binaries
- local()
- system()
- user()
- config
- local()
- system()
- user()
- home()
- log
- local()
- system()
- user()
- temp()## TODO
- ~~Implement polyfill for `os.userInfo`.~~ [common-userinfo](https://www.npmjs.com/package/common-userinfo)
- Implement some sort of `mkdir` when grabbing paths.
- Implement Mac OSX paths, which currently uses the same as POSIX paths.# Development Setup
```
npm install
```NOTE: If you are using an editor and would like to run `gulp` commands in your IDE,
you'll need to also install `gulp-cli` globally.
```
npm install -g gulp-cli
```# License
Copyright 2017 NativeCode DevelopmentPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without
limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so, subject to the following
conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.