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

convert error for node.exe #9

Closed Lvbo163 closed 7 years ago

Lvbo163 commented 7 years ago

Hi, I found this plugin just replace 'node' to 'node --max-old-space-size=5000'. And this is not enough. ie, this is a node.exe in webpack.cmd, by this way, node.exe will be replaced as 'node --max-old-space-size=5000.exe'. could you fix this kind of issue, thanks.

Before: @IF EXIST "%~dp0\node.exe" ( "%~dp0\node.exe" "%~dp0..\webpack\bin\webpack.js" % ) ELSE ( @SETLOCAL @SET PATHEXT=%PATHEXT:;.JS;=;% node "%~dp0..\webpack\bin\webpack.js" % )

After: @IF EXIST "%~dp0\node.exe" ( "%~dp0\node --max-old-space-size=5000.exe" "%~dp0..\webpack\bin\webpack.js" % ) ELSE ( @SETLOCAL @SET PATHEXT=%PATHEXT:;.JS;=;% node --max-old-space-size=5000 "%~dp0..\webpack\bin\webpack.js" % )

toddb commented 7 years ago

The issue is here:

https://github.com/endel/increase-memory-limit/blob/master/index.js#L30

I have patched the code:

patchedContents += line.replace(/node(\.exe)?\b(?: \-\-max\-old\-space\-size\=[0-9]+)?/, `node$1 --max-old-space-size=${maxOldSpaceSice}`) + "\n";

Example output:

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe --max-old-space-size=2048"  "%~dp0\..\acorn\bin\acorn" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node --max-old-space-size=2048  "%~dp0\..\acorn\bin\acorn" %*
)
endel commented 7 years ago

Thanks @toddb for the pull-request, I've just released increase-memory-limit@1.0.5 with your fix.

@Lvbo163 let us know if it works for you now.

Cheers!