-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dima Denysenko
committed
Nov 18, 2023
1 parent
78ae9d7
commit 7b7d6b1
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/sh | ||
|
||
basedir=`dirname "$0"` | ||
|
||
if [ -f "$basedir/mvnw" ]; then | ||
bindir="$basedir/target/node" | ||
repodir="$basedir/target/node/node_modules" | ||
installCommand="$basedir/mvnw -Pwebapp frontend:install-node-and-npm@install-node-and-npm" | ||
|
||
PATH="$basedir/$builddir/:$PATH" | ||
NPM_EXE="$basedir/$builddir/node_modules/npm/bin/npm-cli.js" | ||
NODE_EXE="$basedir/$builddir/node" | ||
elif [ -f "$basedir/gradlew" ]; then | ||
bindir="$basedir/build/node/bin" | ||
repodir="$basedir/build/node/lib/node_modules" | ||
installCommand="$basedir/gradlew npmSetup" | ||
else | ||
echo "Using npm installed globally" | ||
exec npm "$@" | ||
fi | ||
|
||
NPM_EXE="$repodir/npm/bin/npm-cli.js" | ||
NODE_EXE="$bindir/node" | ||
|
||
if [ ! -x "$NPM_EXE" ] || [ ! -x "$NODE_EXE" ]; then | ||
$installCommand || true | ||
fi | ||
|
||
if [ -x "$NODE_EXE" ]; then | ||
echo "Using node installed locally $($NODE_EXE --version)" | ||
PATH="$bindir:$PATH" | ||
else | ||
NODE_EXE='node' | ||
fi | ||
|
||
if [ ! -x "$NPM_EXE" ]; then | ||
echo "Local npm not found, using npm installed globally" | ||
npm "$@" | ||
else | ||
echo "Using npm installed locally $($NODE_EXE $NPM_EXE --version)" | ||
$NODE_EXE $NPM_EXE "$@" | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@echo off | ||
|
||
setlocal | ||
|
||
set NPMW_DIR=%~dp0 | ||
|
||
if exist "%NPMW_DIR%mvnw.cmd" ( | ||
set NODE_EXE=^"^" | ||
set NODE_PATH=%NPMW_DIR%target\node\ | ||
set NPM_EXE=^"%NPMW_DIR%target\node\npm.cmd^" | ||
set INSTALL_NPM_COMMAND=^"%NPMW_DIR%mvnw.cmd^" -Pwebapp frontend:install-node-and-npm@install-node-and-npm | ||
) else ( | ||
set NODE_EXE=^"%NPMW_DIR%build\node\bin\node.exe^" | ||
set NODE_PATH=%NPMW_DIR%build\node\bin\ | ||
set NPM_EXE=^"%NPMW_DIR%build\node\lib\node_modules\npm\bin\npm-cli.js^" | ||
set INSTALL_NPM_COMMAND=^"%NPMW_DIR%gradlew.bat^" npmSetup | ||
) | ||
|
||
if not exist %NPM_EXE% ( | ||
call %INSTALL_NPM_COMMAND% | ||
) | ||
|
||
if exist %NODE_EXE% ( | ||
Rem execute local npm with local node, whilst adding local node location to the PATH for this CMD session | ||
endlocal & echo "%PATH%"|find /i "%NODE_PATH%;">nul || set "PATH=%NODE_PATH%;%PATH%" & call %NODE_EXE% %NPM_EXE% %* | ||
) else if exist %NPM_EXE% ( | ||
Rem execute local npm, whilst adding local npm location to the PATH for this CMD session | ||
endlocal & echo "%PATH%"|find /i "%NODE_PATH%;">nul || set "PATH=%NODE_PATH%;%PATH%" & call %NPM_EXE% %* | ||
) else ( | ||
call npm %* | ||
) |