From 79a0f0611c6235fbf636c3e754860e6de28b4e3c Mon Sep 17 00:00:00 2001
From: Michael Lumish <mlumish@google.com>
Date: Thu, 3 Mar 2016 17:18:48 -0800
Subject: [PATCH] Properly delete Node OpenSSL headers after downloading them

---
 tools/run_tests/build_node.bat     | 10 +++++++++-
 tools/run_tests/pre_build_node.bat |  9 +--------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/tools/run_tests/build_node.bat b/tools/run_tests/build_node.bat
index 6896bc1d1b..3ddd0e73cf 100644
--- a/tools/run_tests/build_node.bat
+++ b/tools/run_tests/build_node.bat
@@ -27,4 +27,12 @@
 @rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-npm install --build-from-source
\ No newline at end of file
+call npm install --build-from-source
+
+@rem delete the redundant openssl headers
+for /f "delims=v" %%v in ('node --version') do (
+  rmdir "%HOMEDRIVE%%HOMEPATH%\.node-gyp\%%v\include\node\openssl" /S /Q
+)
+
+@rem rebuild, because it probably failed the first time
+call npm install --build-from-source
\ No newline at end of file
diff --git a/tools/run_tests/pre_build_node.bat b/tools/run_tests/pre_build_node.bat
index 6e7cbe5d42..ffb4a09f15 100644
--- a/tools/run_tests/pre_build_node.bat
+++ b/tools/run_tests/pre_build_node.bat
@@ -28,12 +28,5 @@
 @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 @rem Expire cache after 1 week
-npm update --cache-min 604800
+call npm update --cache-min 604800
 
-npm install node-gyp-install
-.\node_modules\.bin\node-gyp-install.cmd
-
-@rem delete the redundant openssl headers
-for /f "delims=v" %%v in ('node --version') do (
-  rmdir "%HOMEDRIVE%%HOMEPATH%\.node-gyp\%%v\include\node\openssl" /S /Q
-)
\ No newline at end of file
-- 
GitLab