https://github.com/cnpm/safe-publish-tag
Get the safe publish tag when you `npm publish`
https://github.com/cnpm/safe-publish-tag
Last synced: 10 months ago
JSON representation
Get the safe publish tag when you `npm publish`
- Host: GitHub
- URL: https://github.com/cnpm/safe-publish-tag
- Owner: cnpm
- License: mit
- Created: 2018-09-16T16:54:56.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-13T03:46:55.000Z (over 5 years ago)
- Last Synced: 2025-08-25T20:44:28.300Z (10 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 3
- Watchers: 11
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
README
# safe-publish-tag
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[](https://dev.azure.com/eggjs/egg/_build/latest?definitionId=5)
[![Test coverage][codecov-image]][codecov-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]
[npm-image]: https://img.shields.io/npm/v/safe-publish-tag.svg?style=flat-square
[npm-url]: https://npmjs.com/package/safe-publish-tag
[travis-image]: https://img.shields.io/travis/cnpm/safe-publish-tag.svg?style=flat-square
[travis-url]: https://travis-ci.org/cnpm/safe-publish-tag
[codecov-image]: https://img.shields.io/codecov/c/github/cnpm/safe-publish-tag.svg?style=flat-square
[codecov-url]: https://codecov.io/github/cnpm/safe-publish-tag?branch=master
[snyk-image]: https://snyk.io/test/npm/safe-publish-tag/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/safe-publish-tag
[download-image]: https://img.shields.io/npm/dm/safe-publish-tag.svg?style=flat-square
[download-url]: https://npmjs.com/package/safe-publish-tag
Get the safe publish tag when you `npm publish`.
> Original requirement come from ["Prevent accidental backwards publishing of latest"](https://npm.community/t/prevent-accidental-backwards-publishing-of-latest/2118)
## Install
```bash
$ npm i safe-publish-tag --save
```
## Example
```js
const safePublishTag = require('safe-publish-tag');
safePublishTag('debug', '3.2.5')
.then(tag => {
console.log(tag);
});
// 'latest-3'
safePublishTag('debug', '4.10.0')
.then(tag => {
console.log(tag);
});
// or 'latest' if version greater than the current latest version on npm
```
Use your custom registry
```js
safePublishTag('debug', '4.10.0', { registry: 'https://registry.npm.taobao.org' })
.then(tag => {
console.log(tag);
});
```
## Questions & Suggestions
Please open an issue [here](https://github.com/cnpm/cnpm/issues).
## License
[MIT](LICENSE)