Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TypeScript definition to CommonJS compatible export (#15)
- Loading branch information
1 parent
595ce71
commit e2ac983
Showing
4 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,33 @@ | ||
/** | ||
* Get the set npm registry URL. | ||
* | ||
* @param scope - Retrieve the registry URL associated with an [npm scope](https://docs.npmjs.com/misc/scope). 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. | ||
*/ | ||
export default function registryUrl(scope?: string): string; | ||
declare const registryUrl: { | ||
/** | ||
Get the set npm registry URL. | ||
@param scope - Retrieve the registry URL associated with an [npm scope](https://docs.npmjs.com/misc/scope). 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. | ||
@example | ||
``` | ||
import registryUrl = require('registry-url'); | ||
// # .npmrc | ||
// registry = 'https://custom-registry.com/' | ||
console.log(registryUrl()); | ||
//=> 'https://custom-registry.com/' | ||
// # .npmrc | ||
// @myco:registry = 'https://custom-registry.com/' | ||
console.log(registryUrl('@myco')); | ||
//=> 'https://custom-registry.com/' | ||
``` | ||
*/ | ||
(scope?: string): string; | ||
|
||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function registryUrl(scope?: string): string; | ||
// export = registryUrl; | ||
default: typeof registryUrl; | ||
}; | ||
|
||
export = registryUrl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {expectType} from 'tsd-check'; | ||
import registryUrl from '.'; | ||
import {expectType} from 'tsd'; | ||
import registryUrl = require('.'); | ||
|
||
expectType<string>(registryUrl()); | ||
expectType<string>(registryUrl('@myco')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters