npm.io
0.1.1 • Published 4 months agoCLI

lockfile-sync-check

Licence
MIT
Version
0.1.1
Deps
0
Size
10 kB
Vulns
0
Weekly
0
Stars
2

lockfile-sync-check

NPM Version License

中文文档

A command-line tool to check if your package manager's lockfile is in sync with the latest changes in your Git repository.

Features

  • Supports multiple package managers (npm, yarn, pnpm)
  • Optional automatic dependency installation
  • Easy integration with Git hooks

Installation

npm install -D lockfile-sync-check
# or
yarn add -D lockfile-sync-check
# or
pnpm add -D lockfile-sync-check

Usage

lockfile-sync-check [package-manager] [--install]
Options
  • package-manager: Optional. Specify the package manager to use ("npm", "yarn", or "pnpm"). If not provided, default pnpm.
  • --install: Optional. Automatically install dependencies if the lockfile is out of sync.
Example
# Check if lockfile is in sync, using default package manager (pnpm)
lockfile-sync-check

# Check using specific package manager
lockfile-sync-check npm

# Check and auto-install if out of sync
lockfile-sync-check npm --install

Git Hook Integration

Using simple-git-hooks
  1. Install simple-git-hooks:
npm install -D simple-git-hooks
# or
yarn add -D simple-git-hooks
# or
pnpm add -D simple-git-hooks
  1. Add configuration to your package.json:
{
  "simple-git-hooks": {
    "post-merge": "lockfile-sync-check --install",
    "post-rewrite": "lockfile-sync-check --install"
  }
}
  1. Initialize git hooks:
npx simple-git-hooks
Using Husky
  1. Install Husky:
npm install -D husky
# or
yarn add -D husky
# or
pnpm add -D husky
  1. Initialize Husky:
npx husky install
  1. Add hooks:
npx husky add .husky/post-merge "lockfile-sync-check --install"
npx husky add .husky/post-rewrite "lockfile-sync-check --install"
Manual Setup

Alternatively, you can manually add the script to your .git/hooks/post-merge or .git/hooks/post-rewrite: