All Projects → ljharb → safe-publish-latest

ljharb / safe-publish-latest

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

Programming Languages

javascript
184084 projects - #8 most used programming language

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].