🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

lockfile-version

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lockfile-version

git commit时,限制package-lock文件版本改变

2.0.1
latest
npm
Version published
Weekly downloads
2.4K
-55.79%
Maintainers
1
Weekly downloads
 
Created
Source

✨ lockfile-version

lockfile-version

主要功能:

  • git commit 前,检测 package-lock.json文件版本是否改变,建议配合 husky 使用
  • 限制 package-lock.json 文件版本指定版本
  • 检测当前 node、npm 环境是否满足要求

📦 安装

安装

npm i -D lockfile-version

🔨 使用

直接使用:

npx lockfile-version                   检测git commit前,package-lock.json文件版本是否改变
Options:
  -c,--check-engine                    检查当前的node、npm环境是否满足package.json中engines的限制
  -r,--restrict-version 2              限制具体的lockfileVersion版本,可选版本为:[1,2,3]

额外检查当前的 node、npm 环境,是否满足要求 lockfile-version

npx lockfile-version -c

需要package.json中配置engines

"engines": {
  "node": "7.10.0",
  "npm": "4.2.0"
}

如需指定限制 package-lock.json 文件版本

npx lockfile-version -r=2

🌟 推荐配合 husky 使用

安装 husky 后执行指令:

npx husky add .husky/pre-commit "lockfile-version"

或者编辑.husky/pre-commit

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
// 增加
npx lockfile-version

🔔 其他

lockfileVersion 和 npm、node 版本对应信息

lockfileVersionnpmnode备注
none< 5.0< 8.0未提供版本:来自 npm 5.0 之前的 npm 版本
15.0 ~ 6.08.0 ~ 14.20
27.0 (向下兼容)>= 15.0.0npm 7.0 向下兼容 lockfileVersion 1
37.0>= 15.0.0npm 7.0 (不向下兼容)

FAQs

Package last updated on 09 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts