@@ -6,7 +6,10 @@ import * as fs from "node:fs";
66import * as path from "node:path" ;
77import { pathToFileURL } from "node:url" ;
88
9- export async function setupSpecRunner ( electronRoot : string ) {
9+ export async function setupSpecRunner (
10+ electronRoot : string ,
11+ depotToolsDir : string ,
12+ ) {
1013 const { hashElement } = await import (
1114 pathToFileURL (
1215 path . resolve ( electronRoot , "node_modules" , "folder-hash" , "index.js" ) ,
@@ -23,7 +26,6 @@ export async function setupSpecRunner(electronRoot: string) {
2326 ) ;
2427
2528 const BASE = path . resolve ( electronRoot , ".." ) ;
26- const NPX_CMD = process . platform === "win32" ? "npx.cmd" : "npx" ;
2729
2830 function generateTypeDefinitions ( ) {
2931 const { status } = childProcess . spawnSync (
@@ -85,27 +87,43 @@ export async function setupSpecRunner(electronRoot: string) {
8587 ...process . env ,
8688 CXXFLAGS : process . env . CXXFLAGS ,
8789 npm_config_nodedir : nodeDir ,
88- npm_config_msvs_version : "2019 " ,
90+ npm_config_msvs_version : "2022 " ,
8991 npm_config_yes : "true" ,
9092 } ;
93+ if ( process . platform === "win32" ) {
94+ env . npm_config_python = path . resolve ( depotToolsDir , "python3.bat" ) ;
95+ }
9196 if ( fs . existsSync ( path . resolve ( dir , "node_modules" ) ) ) {
9297 await fs . promises . rm ( path . resolve ( dir , "node_modules" ) , {
9398 force : true ,
9499 recursive : true ,
95100 } ) ;
96101 }
97- const { status } = childProcess . spawnSync (
98- NPX_CMD ,
99- [ `yarn@${ YARN_VERSION } ` , "install" , "--frozen-lockfile" ] ,
102+ const { status, stderr } = childProcess . spawnSync (
103+ "e" ,
104+ [ "d" , "npx" , `yarn@${ YARN_VERSION } ` , "install" , "--frozen-lockfile" ] ,
100105 {
101106 env,
102107 cwd : dir ,
103- stdio : "inherit" ,
108+ stdio : "pipe" ,
109+ shell : process . platform === "win32" ,
110+ encoding : "utf-8" ,
104111 } ,
105112 ) ;
106113 if ( status !== 0 && ! process . env . IGNORE_YARN_INSTALL_ERROR ) {
107- console . log ( `Failed to yarn install in '${ dir } '` ) ;
108- process . exit ( 1 ) ;
114+ if ( stderr . includes ( "missing any VC++ toolset" ) ) {
115+ throw new Error (
116+ `Failed to yarn install in '${ dir } ': missing any VC++ toolset` ,
117+ ) ;
118+ }
119+
120+ if ( stderr . includes ( "missing any Windows SDK" ) ) {
121+ throw new Error (
122+ `Failed to yarn install in '${ dir } ': missing any Windows SDK` ,
123+ ) ;
124+ }
125+
126+ throw new Error ( `Failed to yarn install in '${ dir } ': ${ stderr } ` ) ;
109127 }
110128 }
111129
0 commit comments