๐Ÿ“ฆ ljharb / safe-publish-latest

Ensure that when you `npm publish`, the "latest" tag is only set for the truly latest version.

โ˜… 20 stars โ‘‚ 4 forks ๐Ÿ‘ 20 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/ljharb/safe-publish-latest.git
HTTPS git clone https://github.com/ljharb/safe-publish-latest.git
SSH git clone git@github.com:ljharb/safe-publish-latest.git
CLI gh repo clone ljharb/safe-publish-latest
Jordan Harband Jordan Harband [readme] replace runkit CI badge with shields.io check-runs badge 7c13c55 7 days ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ bin
๐Ÿ“ test
๐Ÿ“„ .editorconfig
๐Ÿ“„ .eslintrc
๐Ÿ“„ .gitignore
๐Ÿ“„ .npmrc
๐Ÿ“„ .nycrc
๐Ÿ“„ CHANGELOG.md
๐Ÿ“„ getLatestError.js
๐Ÿ“„ getTag.js
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ README.md

safe-publish-latest Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Ensure that when you npm publish, the "latest" tag is only set for the truly latest version.

Usage

Add "safe-publish-latest" to your package.json's "prepublish" script, and install in-publish.

It will only activate during an actual npm publish - it will silently do nothing during installs, and will error when run directly.

Example package.json excerpt with no other prepublish commands:

{
	"scripts": {
		"prepublishOnly": "safe-publish-latest",
		"prepublish": "not-in-publish || npm run prepublishOnly"
	}
}

Example package.json excerpt with another prepublish command:

{
	"scripts": {
		"prepublishOnly": "safe-publish-latest && npm run build",
		"prepublish": "not-in-publish || npm run prepublishOnly"
	}
}

Tests

Simply clone the repo, npm install, and run npm test