Last active
February 4, 2016 02:29
-
-
Save mykohsu/b6256301c722d9bec293 to your computer and use it in GitHub Desktop.
Alternative npm.cmd for VS201X node tools integration. Caches npm ls -g result until a different npm command is issued.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: VS201X alternative for %APPDATA%\nodejs\npm.cmd | |
@ECHO OFF | |
SETLOCAL | |
SET "NODE_EXE=%~dp0\node.exe" | |
IF NOT EXIST %NODE_EXE% ( | |
SET PATHEXT=%PATHEXT:;.JS;=;% | |
SET "NODE_EXE=node" | |
) | |
SET "OUTDIR=%~dp0" | |
IF "%1 %2 %3"=="ls -g " ( | |
IF NOT EXIST "%OUTDIR%\npm.ls-g.cache" ( | |
%NODE_EXE% "%~dp0\node_modules\npm\bin\npm-cli.js" %*>>"%OUTDIR%\npm.ls-g.cache" | |
) | |
FOR /F "tokens=2 delims=:" %%F IN ('CALL CHCP') DO ( | |
SET "LS-GCHCP=%%F" | |
) | |
CHCP 65001>nul | |
TYPE "%OUTDIR%\npm.ls-g.cache" | |
CHCP %LS-GCHCP%>nul | |
) ELSE ( | |
ERASE "%OUTDIR%\npm.ls-g.cache" 2>nul | |
%NODE_EXE% "%~dp0\node_modules\npm\bin\npm-cli.js" %* | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good job, it helped!
I forked and updated it to maintain npm original behavior. See it here: https://gist.github.com/giggio/1ba8168628c38b397bde