diff options
Diffstat (limited to 'node_modules/global-prefix')
-rw-r--r-- | node_modules/global-prefix/LICENSE | 4 | ||||
-rw-r--r-- | node_modules/global-prefix/README.md | 26 | ||||
-rw-r--r-- | node_modules/global-prefix/index.js | 84 | ||||
-rw-r--r-- | node_modules/global-prefix/package.json | 34 |
4 files changed, 82 insertions, 66 deletions
diff --git a/node_modules/global-prefix/LICENSE b/node_modules/global-prefix/LICENSE index 1e49edf81..c0d7f1362 100644 --- a/node_modules/global-prefix/LICENSE +++ b/node_modules/global-prefix/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015-2016, Jon Schlinkert. +Copyright (c) 2015-2017, 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 @@ -18,4 +18,4 @@ 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. +THE SOFTWARE.
\ No newline at end of file diff --git a/node_modules/global-prefix/README.md b/node_modules/global-prefix/README.md index 6a227e2c9..31d78ff92 100644 --- a/node_modules/global-prefix/README.md +++ b/node_modules/global-prefix/README.md @@ -1,4 +1,4 @@ -# global-prefix [](https://www.npmjs.com/package/global-prefix) [](https://npmjs.org/package/global-prefix) [](https://travis-ci.org/jonschlinkert/global-prefix) [](https://ci.appveyor.com/project/jonschlinkert/global-prefix) +# 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. @@ -10,13 +10,13 @@ Install with [npm](https://www.npmjs.com/): $ npm install --save global-prefix ``` -This is based on the code used by npm internally to resolve the 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' +//=> '/usr/local' (this path will differ by system and user-defined config) ``` ## About @@ -35,7 +35,9 @@ Pull requests and stars are always welcome. For bugs and feature requests, [plea | **Commits** | **Contributor** | | --- | --- | | 16 | [jonschlinkert](https://github.com/jonschlinkert) | +| 15 | [doowb](https://github.com/doowb) | | 1 | [rmbaad](https://github.com/rmbaad) | +| 1 | [avengerpenguin](https://github.com/avengerpenguin) | | 1 | [jason-chang](https://github.com/jason-chang) | | 1 | [jorrit](https://github.com/jorrit) | | 1 | [mathiasvr](https://github.com/mathiasvr) | @@ -43,20 +45,20 @@ Pull requests and stars are always welcome. For bugs and feature requests, [plea ### Building docs -_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ +_(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 and API documentation with [verb](https://github.com/verbose/verb): +To generate the readme, run the following command: ```sh -$ npm install -g verb verb-generate-readme && verb +$ npm install -g verbose/verb#dev verb-generate-readme && verb ``` ### Running tests -Install dev dependencies: +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 -d && npm test +$ npm install && npm test ``` ### Author @@ -64,13 +66,13 @@ $ npm install -d && npm test **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) -* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) +* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) ### License -Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). -Released under the [MIT license](LICENSE). +Copyright © 2017, [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.2.0, on November 30, 2016._
\ No newline at end of file +_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 28, 2017._
\ No newline at end of file diff --git a/node_modules/global-prefix/index.js b/node_modules/global-prefix/index.js index fa19422ff..cc66d952a 100644 --- a/node_modules/global-prefix/index.js +++ b/node_modules/global-prefix/index.js @@ -1,46 +1,52 @@ /*! * global-prefix <https://github.com/jonschlinkert/global-prefix> * - * Copyright (c) 2015 Jon Schlinkert. + * Copyright (c) 2015-2017 Jon Schlinkert. * Licensed under the MIT license. */ 'use strict'; -var homedir = require('homedir-polyfill'); +var fs = require('fs'); var path = require('path'); +var expand = require('expand-tilde'); +var homedir = require('homedir-polyfill'); var ini = require('ini'); -var fs = require('fs') - var prefix; -if (process.env.PREFIX) { - prefix = process.env.PREFIX; -} else { - // Start by checking if the global prefix is set by the user - var home = homedir(); - if (home) { - // homedir() returns undefined if $HOME not set; path.resolve requires strings - var userConfig = path.resolve(home, '.npmrc'); - prefix = readPrefix(userConfig); - } +function getPrefix() { + if (process.env.PREFIX) { + prefix = process.env.PREFIX; + } else { + // Start by checking if the global prefix is set by the user + var home = homedir(); + if (home) { + // homedir() returns undefined if $HOME not set; path.resolve requires strings + var userConfig = path.resolve(home, '.npmrc'); + prefix = tryConfigPath(userConfig); + } - if (!prefix) { - // Otherwise find the path of npm - var npm = npmPath(); - if (npm) { - // Check the built-in npm config file - var builtinConfig = path.resolve(npm, '..', '..', 'npmrc'); - prefix = readPrefix(builtinConfig); + if (!prefix) { + // Otherwise find the path of npm + var npm = tryNpmPath(); + if (npm) { + // Check the built-in npm config file + var builtinConfig = path.resolve(npm, '..', '..', 'npmrc'); + prefix = tryConfigPath(builtinConfig); - if (prefix) { - // Now the global npm config can also be checked. - var globalConfig = path.resolve(prefix, 'etc', 'npmrc'); - prefix = readPrefix(globalConfig) || prefix; + if (prefix) { + // Now the global npm config can also be checked. + var globalConfig = path.resolve(prefix, 'etc', 'npmrc'); + prefix = tryConfigPath(globalConfig) || prefix; + } } + + if (!prefix) fallback(); } + } - if (!prefix) fallback(); + if (prefix) { + return expand(prefix); } } @@ -62,23 +68,29 @@ function fallback() { } } -function npmPath() { +function tryNpmPath() { try { return fs.realpathSync(require('which').sync('npm')); - } catch (ex) { - } - return false; + } catch (err) {} + return null; } -function readPrefix(configPath) { +function tryConfigPath(configPath) { try { var data = fs.readFileSync(configPath, 'utf-8'); var config = ini.parse(data); if (config.prefix) return config.prefix; - } catch (ex) { - // file not found - } - return false; + } catch (err) {} + return null; } -module.exports = prefix; +/** + * Expose `prefix` + */ + +Object.defineProperty(module, 'exports', { + enumerable: true, + get: function() { + return prefix || (prefix = getPrefix()); + } +}); diff --git a/node_modules/global-prefix/package.json b/node_modules/global-prefix/package.json index 4dc678600..7d366a67b 100644 --- a/node_modules/global-prefix/package.json +++ b/node_modules/global-prefix/package.json @@ -1,9 +1,19 @@ { "name": "global-prefix", "description": "Get the npm global path prefix.", - "version": "0.1.5", + "version": "1.0.2", "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" @@ -20,15 +30,15 @@ "test": "mocha" }, "dependencies": { - "homedir-polyfill": "^1.0.0", + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", "ini": "^1.3.4", - "is-windows": "^0.2.0", - "which": "^1.2.12" + "is-windows": "^1.0.1", + "which": "^1.2.14" }, "devDependencies": { - "fs-exists-sync": "^0.1.0", - "gulp-format-md": "^0.1.11", - "mocha": "^3.2.0" + "gulp-format-md": "^0.1.12", + "mocha": "^3.4.2" }, "keywords": [ "global", @@ -61,13 +71,5 @@ "lint": { "reflinks": true } - }, - "contributors": [ - "Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)", - "Alexandr Bogachev <kuksikus@gmail.com> (https://github.com/rmbaad)", - "JasonChang <chaoyue.chang@qq.com> (https://packagist.org/packages/jason-chang)", - "Jorrit Schippers (https://www.ncode.nl)", - "Mathias Rasmussen (https://github.com/mathiasvr)", - "Charlike Mike Reagent (http://i.am.charlike.online)" - ] + } } |