endel / increase-memory-limit

Increase memory limit for local node binaries ("max-old-space-size")
http://npmjs.com/package/increase-memory-limit
MIT License
269 stars 26 forks source link

if a node module contains node in it's package it alters it's name #3

Closed sandorfr closed 7 years ago

sandorfr commented 7 years ago

Currently, it blindly replaces any occurence of node in the cmd/shell files no matter where they are.

So if a node module has node in its name, it will replace it as well leading to an invalid path.

Example cmd:

@IF EXIST "%~dp0\node --max-old-space-size=10240.exe" (
  "%~dp0\node --max-old-space-size=10240.exe"  "%~dp0\..\node --max-old-space-size=10240-swagger-generator\run\swaggen" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node --max-old-space-size=10240  "%~dp0\..\node --max-old-space-size=10240-swagger-generator\run\swaggen" %*
)

Example shell:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node --max-old-space-size=10240" ]; then
  "$basedir/node --max-old-space-size=10240"  "$basedir/../node --max-old-space-size=10240-swagger-generator/run/swaggen" "$@"
  ret=$?
else 
  node --max-old-space-size=10240  "$basedir/../node --max-old-space-size=10240-swagger-generator/run/swaggen" "$@"
  ret=$?
fi
exit $ret

I also have the feeling that the if statement should also be left untouched.

Thanks for that handy command by the way.

sandorfr commented 7 years ago

I have submitted a PR which addresses this issue.

endel commented 7 years ago

Thanks @sandorfr! It works on Windows using your fix now, right?

sandorfr commented 7 years ago

Yes, it works :) thank you for the prompt merge/publish. And some advertisement for this tool : http://geeklearning.io/angular-aot-webpack-memory-trick/