-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
5cd4fc2
commit b263306
Showing
8 changed files
with
47 additions
and
72 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
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,42 +1,26 @@ | ||
declare namespace latestVersion { | ||
interface Options { | ||
/** | ||
A semver range or [dist-tag](https://docs.npmjs.com/cli/dist-tag). | ||
*/ | ||
readonly version?: string; | ||
} | ||
} | ||
|
||
declare const latestVersion: { | ||
export interface Options { | ||
/** | ||
Get the latest version of an npm package. | ||
@example | ||
``` | ||
import latestVersion = require('latest-version'); | ||
A semver range or [dist-tag](https://docs.npmjs.com/cli/dist-tag). | ||
*/ | ||
readonly version?: string; | ||
} | ||
|
||
(async () => { | ||
console.log(await latestVersion('ava')); | ||
//=> '0.18.0' | ||
/** | ||
Get the latest version of an npm package. | ||
console.log(await latestVersion('@sindresorhus/df')); | ||
//=> '1.0.1' | ||
@example | ||
``` | ||
import latestVersion from 'latest-version'; | ||
// Also works with semver ranges and dist-tags | ||
console.log(await latestVersion('npm', {version: 'latest-5'})); | ||
//=> '5.5.1' | ||
})(); | ||
``` | ||
*/ | ||
(packageName: string, options?: latestVersion.Options): Promise<string>; | ||
console.log(await latestVersion('ava')); | ||
//=> '0.18.0' | ||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function latestVersion( | ||
// packageName: string, | ||
// options?: latestVersion.Options | ||
// ): Promise<string>; | ||
// export = latestVersion; | ||
default: typeof latestVersion; | ||
}; | ||
console.log(await latestVersion('@sindresorhus/df')); | ||
//=> '1.0.1' | ||
export = latestVersion; | ||
// Also works with semver ranges and dist-tags | ||
console.log(await latestVersion('npm', {version: 'latest-5'})); | ||
//=> '5.5.1' | ||
``` | ||
*/ | ||
export default function latestVersion(packageName: string, options?: Options): Promise<string>; |
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,11 +1,6 @@ | ||
'use strict'; | ||
const packageJson = require('package-json'); | ||
import packageJson from 'package-json'; | ||
|
||
const latestVersion = async (packageName, options) => { | ||
export default async function latestVersion(packageName, options) { | ||
const {version} = await packageJson(packageName.toLowerCase(), options); | ||
return version; | ||
}; | ||
|
||
module.exports = latestVersion; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = latestVersion; | ||
} |
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'; | ||
import latestVersion = require('.'); | ||
import latestVersion from './index.js'; | ||
|
||
expectType<Promise<string>>(latestVersion('ava')); | ||
expectType<Promise<string>>(latestVersion('npm', {version: 'latest-5'})); |
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,6 @@ | ||
MIT License | ||
|
||
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com) | ||
Copyright (c) Sindre Sorhus <[email protected]> (https://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: | ||
|
||
|
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 |
---|---|---|
|
@@ -4,13 +4,16 @@ | |
"description": "Get the latest version of an npm package", | ||
"license": "MIT", | ||
"repository": "sindresorhus/latest-version", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "[email protected]", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=12.20" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
|
@@ -30,13 +33,13 @@ | |
"module" | ||
], | ||
"dependencies": { | ||
"package-json": "^6.3.0" | ||
"package-json": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"semver": "^6.0.0", | ||
"semver-regex": "^2.0.0", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"semver": "^7.3.5", | ||
"semver-regex": "^4.0.0", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.42.0" | ||
} | ||
} |
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