@@ -5,14 +5,34 @@ import * as dotenv from 'dotenv';
5
5
import { sync as globSync } from 'glob' ;
6
6
7
7
import { registrySetup } from './registrySetup' ;
8
+ import { readFileSync } from 'fs' ;
8
9
9
10
const DEFAULT_DSN = 'https://username@domain/123' ;
10
11
const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks' ;
11
12
const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests' ;
12
13
13
- function asyncExec ( command : string , options : { env : Record < string , string | undefined > ; cwd : string } ) : Promise < void > {
14
+ interface PackageJson {
15
+ volta ?: {
16
+ node ?: string ;
17
+ } ;
18
+ }
19
+
20
+ function getVoltaNodeVersion ( packageJsonPath : string ) : string | undefined {
21
+ try {
22
+ const packageJson : PackageJson = JSON . parse ( readFileSync ( packageJsonPath , 'utf8' ) ) ;
23
+ return packageJson . volta ?. node ;
24
+ } catch {
25
+ return undefined ;
26
+ }
27
+ }
28
+
29
+ function asyncExec (
30
+ command : string ,
31
+ options : { env : Record < string , string | undefined > ; cwd : string ; nodeVersion ?: string } ,
32
+ ) : Promise < void > {
14
33
return new Promise ( ( resolve , reject ) => {
15
- const process = spawn ( command , { ...options , shell : true } ) ;
34
+ const finalCommand = options . nodeVersion ? `volta run --node ${ options . nodeVersion } ${ command } ` : command ;
35
+ const process = spawn ( finalCommand , { ...options , shell : true } ) ;
16
36
17
37
process . stdout . on ( 'data' , data => {
18
38
console . log ( `${ data } ` ) ;
@@ -75,12 +95,13 @@ async function run(): Promise<void> {
75
95
76
96
for ( const testAppPath of testAppPaths ) {
77
97
const cwd = resolve ( 'test-applications' , testAppPath ) ;
98
+ const nodeVersion = getVoltaNodeVersion ( resolve ( cwd , 'package.json' ) ) ;
78
99
79
100
console . log ( `Building ${ testAppPath } ...` ) ;
80
- await asyncExec ( 'pnpm test:build' , { env, cwd } ) ;
101
+ await asyncExec ( 'pnpm test:build' , { env, cwd, nodeVersion } ) ;
81
102
82
103
console . log ( `Testing ${ testAppPath } ...` ) ;
83
- await asyncExec ( 'pnpm test:assert' , { env, cwd } ) ;
104
+ await asyncExec ( 'pnpm test:assert' , { env, cwd, nodeVersion } ) ;
84
105
}
85
106
} catch ( error ) {
86
107
console . error ( error ) ;
0 commit comments