Skip to content

Instantly share code, notes, and snippets.

@s-h-a-d-o-w
Created June 28, 2024 11:09
Show Gist options
  • Save s-h-a-d-o-w/d1be4eb4ecad3576af8fa69c248be615 to your computer and use it in GitHub Desktop.
Save s-h-a-d-o-w/d1be4eb4ecad3576af8fa69c248be615 to your computer and use it in GitHub Desktop.
Batch script - "smart" package manager command for JS projects
@echo off
setlocal
if exist package-lock.json (
set PM=npm
) else if exist yarn.lock (
set PM=yarn
) else if exist pnpm-lock.yaml (
set PM=pnpm
) else if exist bun.lockb (
set PM=bun
) else (
echo No recognized lockfile found. Exiting...
exit /b 1
)
call %PM% %*
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment