pax_global_header00006660000000000000000000000064127004771660014524gustar00rootroot0000000000000052 comment=79d07a452fe0c990fa0b154d510c68fc483b4689 registry-url-3.1.0/000077500000000000000000000000001270047716600141755ustar00rootroot00000000000000registry-url-3.1.0/.editorconfig000066400000000000000000000002761270047716600166570ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 registry-url-3.1.0/.gitattributes000066400000000000000000000000141270047716600170630ustar00rootroot00000000000000* text=auto registry-url-3.1.0/.gitignore000066400000000000000000000000151270047716600161610ustar00rootroot00000000000000node_modules registry-url-3.1.0/.travis.yml000066400000000000000000000001151270047716600163030ustar00rootroot00000000000000sudo: false language: node_js node_js: - '5' - '4' - '0.12' - '0.10' registry-url-3.1.0/index.js000066400000000000000000000003441270047716600156430ustar00rootroot00000000000000'use strict'; module.exports = function (scope) { var rc = require('rc')('npm', {registry: 'https://registry.npmjs.org/'}); var url = rc[scope + ':registry'] || rc.registry; return url.slice(-1) === '/' ? url : url + '/'; }; registry-url-3.1.0/license000066400000000000000000000021371270047716600155450ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) 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. registry-url-3.1.0/package.json000066400000000000000000000012641270047716600164660ustar00rootroot00000000000000{ "name": "registry-url", "version": "3.1.0", "description": "Get the set npm registry URL", "license": "MIT", "repository": "sindresorhus/registry-url", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava --serial" }, "files": [ "index.js" ], "keywords": [ "npm", "conf", "config", "npmconf", "registry", "url", "uri", "scope" ], "dependencies": { "rc": "^1.0.1" }, "devDependencies": { "ava": "*", "pify": "^2.3.0", "require-uncached": "^1.0.2", "xo": "*" } } registry-url-3.1.0/readme.md000066400000000000000000000022731270047716600157600ustar00rootroot00000000000000# registry-url [![Build Status](https://travis-ci.org/sindresorhus/registry-url.svg?branch=master)](https://travis-ci.org/sindresorhus/registry-url) > Get the set npm registry URL It's usually `https://registry.npmjs.org/`, but [configurable](https://www.npmjs.org/doc/misc/npm-config.html#registry). Use this if you do anything with the npm registry as users will expect it to use their configured registry. ## Install ``` $ npm install --save registry-url ``` ## Usage ```ini # .npmrc registry = 'https://custom-registry.com/' ``` ```js const registryUrl = require('registry-url'); console.log(registryUrl()); //=> 'https://custom-registry.com/' ``` It can also retrieve the registry URL associated with an [npm scope](https://docs.npmjs.com/misc/scope). ```ini # .npmrc @myco:registry = 'https://custom-registry.com/' ``` ```js const registryUrl = require('registry-url'); console.log(registryUrl('@myco')); //=> 'https://custom-registry.com/' ``` If the provided scope is not in the user's `.npmrc` file, then `registry-url` will check for the existence of `registry`, or if that's not set, fallback to the default npm registry. ## License MIT © [Sindre Sorhus](http://sindresorhus.com) registry-url-3.1.0/test.js000066400000000000000000000025511270047716600155150ustar00rootroot00000000000000import fs from 'fs'; import test from 'ava'; import pify from 'pify'; import requireUncached from 'require-uncached'; const fsP = pify(fs, Promise); test.afterEach(async () => { try { await fsP.unlink('.npmrc'); } catch (err) { if (err.code !== 'ENOENT') { throw err; } } }); test('get the npm registry URL globally', t => { t.ok(requireUncached('./')().length); }); test('get the npm registry URL locally', async t => { await fsP.writeFile('.npmrc', 'registry=http://registry.npmjs.eu/'); t.is(requireUncached('./')(), 'http://registry.npmjs.eu/'); }); test('get local scope registry URL', async t => { await fsP.writeFile('.npmrc', '@myco:registry=http://reg.example.com/'); t.is(requireUncached('./')('@myco'), 'http://reg.example.com/'); }); test('return default npm registry when scope registry is not set', async t => { await fsP.writeFile('.npmrc', ''); t.is(requireUncached('./')('@invalidScope'), 'https://registry.npmjs.org/'); }); test('add trailing slash to local npm registry URL', async t => { await fsP.writeFile('.npmrc', 'registry=http://registry.npmjs.eu'); t.is(requireUncached('./')(), 'http://registry.npmjs.eu/'); }); test('add trailing slash to local scope registry URL', async t => { await fsP.writeFile('.npmrc', '@myco:registry=http://reg.example.com'); t.is(requireUncached('./')('@myco'), 'http://reg.example.com/'); });