1. safe-publish-latest
Ensure that when you `npm publish`, the "latest" tag is only set for the truly latest version.
safe-publish-latest
Package: safe-publish-latest
Created by: ljharb
Last modified: Sun, 26 Jun 2022 15:20:02 GMT
Version: 2.0.0
License: MIT
Downloads: 74,794
Repository: https://github.com/ljharb/safe-publish-latest

Install

npm install safe-publish-latest
yarn add safe-publish-latest

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

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code