@@ -41,29 +41,39 @@ function getDefaultLinuxVersion(osVersion: number[], toolLinuxVersions: Record<n
41
41
* @param tools - The tools to sync the versions for (it can include `compiler`)
42
42
* @param compilerInfo - The compiler info to sync the versions for (if any)
43
43
*/
44
- export function syncVersions ( opts : Opts , tools : Inputs [ ] , compilerInfo : CompilerInfo | undefined = undefined ) : boolean {
44
+ export function syncVersions (
45
+ opts : Opts ,
46
+ toolsGiven : Inputs [ ] ,
47
+ compilerInfo : CompilerInfo | undefined = undefined ,
48
+ ) : boolean {
49
+ // check if compiler version should be synced
50
+ const syncCompiler = compilerInfo === undefined ? false : toolsGiven . includes ( compilerInfo . compiler as Inputs )
51
+
52
+ // remove the compiler from the tools if it should not be synced
53
+ const tools = syncCompiler ? toolsGiven : toolsGiven . filter ( ( tool ) => tool !== "compiler" )
54
+
45
55
// filter out the tools that are in use in the options
46
56
const toolsInUse = tools . filter ( ( tool ) => opts [ tool ] !== undefined )
47
57
48
58
// filter out the tools that are not default
49
59
const toolsNonDefaultVersion = toolsInUse . filter ( ( tool ) => {
50
- const version = ( tool === "compiler" && compilerInfo !== undefined )
60
+ const version = ( syncCompiler && tool === "compiler" && compilerInfo !== undefined )
51
61
? compilerInfo . version
52
62
: opts [ tool ]
53
63
return ! isVersionDefault ( version )
54
64
} )
55
65
56
66
// find the target version to sync to
57
67
const targetVersion : string = ( toolsNonDefaultVersion . length !== 0 )
58
- ? ( toolsNonDefaultVersion [ 0 ] === "compiler" && compilerInfo !== undefined )
68
+ ? ( syncCompiler && toolsNonDefaultVersion [ 0 ] === "compiler" && compilerInfo !== undefined )
59
69
? compilerInfo . version ?? "true"
60
70
: opts [ toolsNonDefaultVersion [ 0 ] ] ?? "true"
61
71
: "true"
62
72
63
73
// error if any explicit versions don't match the target version
64
74
if (
65
75
toolsNonDefaultVersion . some ( ( tool ) => {
66
- if ( tool === "compiler" && compilerInfo !== undefined ) {
76
+ if ( syncCompiler && tool === "compiler" && compilerInfo !== undefined ) {
67
77
return opts . compiler !== `${ compilerInfo . compiler } -${ targetVersion } `
68
78
}
69
79
@@ -75,7 +85,7 @@ export function syncVersions(opts: Opts, tools: Inputs[], compilerInfo: Compiler
75
85
76
86
// update the version of all the tools to the target version
77
87
for ( const tool of toolsInUse ) {
78
- opts [ tool ] = ( tool === "compiler" && compilerInfo !== undefined )
88
+ opts [ tool ] = ( syncCompiler && tool === "compiler" && compilerInfo !== undefined )
79
89
? `${ compilerInfo . compiler } -${ targetVersion } `
80
90
: targetVersion
81
91
}
0 commit comments