From c591ecf5182112ebbcc732ffe70b120945d7de11 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Mon, 15 May 2023 02:10:22 -0700 Subject: [PATCH] test: prewarm Node headers cache if specifying Electron version (#38287) --- script/spec-runner.js | 12 ++++++++++++ spec/package.json | 3 +++ 2 files changed, 15 insertions(+) diff --git a/script/spec-runner.js b/script/spec-runner.js index 8edc5d44d2..1b828713f0 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -5,6 +5,7 @@ const childProcess = require('child_process'); const crypto = require('crypto'); const fs = require('fs-extra'); const { hashElement } = require('folder-hash'); +const os = require('os'); const path = require('path'); const unknownFlags = []; @@ -260,7 +261,18 @@ async function installSpecModules (dir) { env.npm_config_target = args.electronVersion; env.npm_config_disturl = 'https://electronjs.org/headers'; env.npm_config_runtime = 'electron'; + env.npm_config_devdir = path.join(os.homedir(), '.electron-gyp'); env.npm_config_build_from_source = 'true'; + const { status } = childProcess.spawnSync('npm', ['run', 'node-gyp-install', '--ensure'], { + env, + cwd: dir, + stdio: 'inherit', + shell: true + }); + if (status !== 0) { + console.log(`${fail} Failed to "npm run node-gyp-install" install in '${dir}'`); + process.exit(1); + } } else { env.npm_config_nodedir = path.resolve(BASE, `out/${utils.getOutDir({ shouldLog: true })}/gen/node_headers`); } diff --git a/spec/package.json b/spec/package.json index f6ec238205..0cd30efaef 100644 --- a/spec/package.json +++ b/spec/package.json @@ -3,6 +3,9 @@ "productName": "Electron Test Main", "main": "index.js", "version": "0.1.0", + "scripts": { + "node-gyp-install": "node-gyp install" + }, "devDependencies": { "@electron-ci/echo": "file:./fixtures/native-addon/echo", "@electron-ci/uv-dlopen": "file:./fixtures/native-addon/uv-dlopen/",