pax_global_header 0000666 0000000 0000000 00000000064 13405064372 0014516 g ustar 00root root 0000000 0000000 52 comment=13eba037352188a9c421151a473a61ff37096a7d
global-prefix-3.0.0/ 0000775 0000000 0000000 00000000000 13405064372 0014251 5 ustar 00root root 0000000 0000000 global-prefix-3.0.0/.editorconfig 0000664 0000000 0000000 00000000327 13405064372 0016730 0 ustar 00root root 0000000 0000000 # http://editorconfig.org/
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
global-prefix-3.0.0/.eslintrc.json 0000664 0000000 0000000 00000007325 13405064372 0017054 0 ustar 00root root 0000000 0000000 {
"extends": [
"eslint:recommended"
],
"env": {
"browser": false,
"es6": true,
"node": true,
"mocha": true
},
"parserOptions":{
"ecmaVersion": 9,
"sourceType": "module",
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true
}
},
"globals": {
"document": false,
"navigator": false,
"window": false
},
"rules": {
"accessor-pairs": 2,
"arrow-spacing": [2, { "before": true, "after": true }],
"block-spacing": [2, "always"],
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"comma-dangle": [2, "never"],
"comma-spacing": [2, { "before": false, "after": true }],
"comma-style": [2, "last"],
"constructor-super": 2,
"curly": [2, "multi-line"],
"dot-location": [2, "property"],
"eol-last": 2,
"eqeqeq": [2, "allow-null"],
"generator-star-spacing": [2, { "before": true, "after": true }],
"handle-callback-err": [2, "^(err|error)$" ],
"indent": [2, 2, { "SwitchCase": 1 }],
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"keyword-spacing": [2, { "before": true, "after": true }],
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-class-assign": 2,
"no-cond-assign": 2,
"no-const-assign": 2,
"no-control-regex": 2,
"no-debugger": 2,
"no-delete-var": 2,
"no-dupe-args": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-eval": 2,
"no-ex-assign": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-parens": [2, "functions"],
"no-fallthrough": 2,
"no-floating-decimal": 2,
"no-func-assign": 2,
"no-implied-eval": 2,
"no-inner-declarations": [2, "functions"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-native-reassign": 0,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-require": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-octal": 2,
"no-octal-escape": 2,
"no-proto": 0,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-return-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 0,
"no-undef": 2,
"no-undef-init": 2,
"no-unexpected-multiline": 2,
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
"no-unreachable": 2,
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
"no-useless-call": 0,
"no-with": 2,
"one-var": [0, { "initialized": "never" }],
"operator-linebreak": [0, "after", { "overrides": { "?": "before", ":": "before" } }],
"padded-blocks": [0, "never"],
"quotes": [2, "single", "avoid-escape"],
"radix": 2,
"semi": [2, "always"],
"semi-spacing": [2, { "before": false, "after": true }],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, "never"],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [0, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
"use-isnan": 2,
"valid-typeof": 2,
"wrap-iife": [2, "any"],
"yoda": [2, "never"]
}
}
global-prefix-3.0.0/.gitattributes 0000664 0000000 0000000 00000000177 13405064372 0017151 0 ustar 00root root 0000000 0000000 # Enforce Unix newlines
* text eol=lf
# binaries
*.ai binary
*.psd binary
*.jpg binary
*.gif binary
*.png binary
*.jpeg binary global-prefix-3.0.0/.gitignore 0000664 0000000 0000000 00000000440 13405064372 0016237 0 ustar 00root root 0000000 0000000 # always ignore files
*.DS_Store
*.sublime-*
# test related, or directories generated by tests
test/actual
actual
coverage
.nyc*
# npm
node_modules
npm-debug.log
# yarn
yarn.lock
yarn-error.log
# misc
_gh_pages
_draft
_drafts
bower_components
vendor
temp
tmp
TODO.md
package-lock.json global-prefix-3.0.0/.npmrc 0000664 0000000 0000000 00000000023 13405064372 0015364 0 ustar 00root root 0000000 0000000 package-lock=false
global-prefix-3.0.0/.travis.yml 0000664 0000000 0000000 00000000204 13405064372 0016356 0 ustar 00root root 0000000 0000000 sudo: false
os:
- linux
- osx
- windows
language: node_js
node_js:
- node
- '11'
- '10'
- '9'
- '8'
- '7'
- '6'
global-prefix-3.0.0/.verb.md 0000664 0000000 0000000 00000000337 13405064372 0015612 0 ustar 00root root 0000000 0000000 This is partially based on the code used by npm internally to resolve the global prefix.
## Usage
```js
var prefix = require('{%= name %}');
//=> '/usr/local' (this path will differ by system and user-defined config)
```
global-prefix-3.0.0/LICENSE 0000664 0000000 0000000 00000002103 13405064372 0015252 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2015-present, Jon Schlinkert.
Permission 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.
global-prefix-3.0.0/README.md 0000664 0000000 0000000 00000007534 13405064372 0015541 0 ustar 00root root 0000000 0000000 # global-prefix [](https://www.npmjs.com/package/global-prefix) [](https://npmjs.org/package/global-prefix) [](https://npmjs.org/package/global-prefix) [](https://travis-ci.org/jonschlinkert/global-prefix) [](https://ci.appveyor.com/project/jonschlinkert/global-prefix)
> Get the npm global path prefix.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save global-prefix
```
This is partially based on the code used by npm internally to resolve the global prefix.
## Usage
```js
var prefix = require('global-prefix');
//=> '/usr/local' (this path will differ by system and user-defined config)
```
## About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Related projects
You might also be interested in these projects:
* [global-modules](https://www.npmjs.com/package/global-modules): The directory used by npm for globally installed npm modules. | [homepage](https://github.com/jonschlinkert/global-modules "The directory used by npm for globally installed npm modules.")
* [global-paths](https://www.npmjs.com/package/global-paths): Returns an array of unique "global" directories based on the user's platform and environment. The… [more](https://github.com/jonschlinkert/global-paths) | [homepage](https://github.com/jonschlinkert/global-paths "Returns an array of unique "global" directories based on the user's platform and environment. The resulting paths can be used for doing lookups for generators or other globally installed npm packages. Node.js / JavaScript.")
### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 23 | [jonschlinkert](https://github.com/jonschlinkert) |
| 15 | [doowb](https://github.com/doowb) |
| 2 | [phated](https://github.com/phated) |
| 1 | [rmbaad](https://github.com/rmbaad) |
| 1 | [avengerpenguin](https://github.com/avengerpenguin) |
| 1 | [jorrit](https://github.com/jorrit) |
| 1 | [mathiasvr](https://github.com/mathiasvr) |
| 1 | [tunnckoCore](https://github.com/tunnckoCore) |
### Author
**Jon Schlinkert**
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
### License
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on October 11, 2018._ global-prefix-3.0.0/index.js 0000664 0000000 0000000 00000003720 13405064372 0015720 0 ustar 00root root 0000000 0000000 /*!
* global-prefix
*
* Copyright (c) 2015-present Jon Schlinkert.
* Licensed under the MIT license.
*/
'use strict';
const fs = require('fs');
const os = require('os');
const path = require('path');
const ini = require('ini');
let prefix;
const getPrefix = () => {
if (process.env.PREFIX) return process.env.PREFIX;
if (prefix) return prefix;
// Start by checking if the global prefix is set by the user
let home = os.homedir();
// os.homedir() returns undefined if $HOME is not set; path.resolve requires strings
if (home) {
prefix = tryConfigPath(path.resolve(home, '.npmrc'));
}
if (prefix) {
return prefix;
}
// Otherwise find the path of npm
let npm = tryNpmPath();
if (npm) {
// Check the built-in npm config file
prefix = tryConfigPath(path.resolve(npm, '..', '..', 'npmrc'));
if (prefix) {
// Now the global npm config can also be checked.
prefix = tryConfigPath(path.resolve(prefix, 'etc', 'npmrc')) || prefix;
}
}
if (!prefix) {
let { APPDATA, DESTDIR, OSTYPE } = process.env;
// c:\node\node.exe --> prefix=c:\node\
if (process.platform === 'win32' || OSTYPE === 'msys' || OSTYPE === 'cygwin') {
prefix = APPDATA ? path.join(APPDATA, 'npm') : path.dirname(process.execPath);
return prefix;
}
// /usr/local/bin/node --> prefix=/usr/local
prefix = path.dirname(path.dirname(process.execPath));
// destdir only is respected on Unix
if (DESTDIR) {
prefix = path.join(DESTDIR, prefix);
}
}
return prefix;
}
function tryNpmPath() {
try {
return fs.realpathSync(require('which').sync('npm'));
} catch (err) { /* do nothing */ }
}
function tryConfigPath(configPath) {
try {
return ini.parse(fs.readFileSync(configPath, 'utf-8')).prefix;
} catch (err) { /* do nothing */ }
}
/**
* Expose `prefix`
*/
Reflect.defineProperty(module, 'exports', {
get() {
return getPrefix();
}
});
global-prefix-3.0.0/package.json 0000664 0000000 0000000 00000002341 13405064372 0016537 0 ustar 00root root 0000000 0000000 {
"name": "global-prefix",
"description": "Get the npm global path prefix.",
"version": "3.0.0",
"homepage": "https://github.com/jonschlinkert/global-prefix",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"contributors": [
"Alexandr Bogachev (https://github.com/rmbaad)",
"Brian Woodward (https://twitter.com/doowb)",
"Charlike Mike Reagent (https://i.am.charlike.online)",
"JasonChang (https://packagist.org/packages/jason-chang)",
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
"Jorrit Schippers (https://www.ncode.nl)",
"Mathias Rasmussen (chrome://dino)",
"Ross Fenning (http://rossfenning.co.uk)"
],
"repository": "jonschlinkert/global-prefix",
"bugs": {
"url": "https://github.com/jonschlinkert/global-prefix/issues"
},
"license": "MIT",
"files": [
"index.js"
],
"main": "index.js",
"engines": {
"node": ">=6"
},
"scripts": {
"test": "mocha"
},
"dependencies": {
"ini": "^1.3.5",
"kind-of": "^6.0.2",
"which": "^1.3.1"
},
"devDependencies": {
"gulp-format-md": "^2.0.0",
"mocha": "^5.2.0"
},
"keywords": [
"global",
"module",
"modules",
"npm",
"path",
"prefix",
"resolve"
]
}
global-prefix-3.0.0/test.js 0000664 0000000 0000000 00000001252 13405064372 0015566 0 ustar 00root root 0000000 0000000 /*!
* global-prefix
*
* Copyright (c) 2015 Jon Schlinkert.
* Licensed under the MIT license.
*/
'use strict';
require('mocha');
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const prefix = require('./');
describe('prefix', () => {
it('should resolve the path to the windows global prefix', () => {
if (process.platform === 'win32') {
assert.equal(prefix, process.env.APPDATA ? path.join(process.env.APPDATA, 'npm') : path.dirname(process.execPath));
}
});
it('should resolve the path to the global prefix', () => {
assert(fs.existsSync(prefix));
});
});