@@ -14,6 +14,8 @@ export type PackageInfo = {
1414 extractedFolderName : string
1515 /** The relative directory in which the binary is located. It can be `""` if the exe is in the top folder */
1616 binRelativeDir : string
17+ /** The main binary file. */
18+ binFileName : string
1719 /** The function to extract the downloaded archive. It can be `undefined`, if the binary itself is downloaded directly. */
1820 extractFunction ?: {
1921 ( file : string , dest : string ) : Promise < string > | Promise < void >
@@ -42,36 +44,42 @@ export async function setupBin(
4244 setupDir : string
4345) : Promise < InstallationInfo > {
4446 process . env . RUNNER_TEMP = process . env . RUNNER_TEMP ?? tmpdir ( )
45- process . env . RUNNER_TOOL_CACHE = process . env . RUNNER_TOOL_CACH ?? join ( tmpdir ( ) , "setup_cpp " , "ToolCache" )
47+ process . env . RUNNER_TOOL_CACHE = process . env . RUNNER_TOOL_CACH ?? join ( tmpdir ( ) , "setup-cpp " , "ToolCache" )
4648
47- const { url, binRelativeDir, extractedFolderName, extractFunction } = await getPackageInfo ( version , process . platform )
49+ const { url, binRelativeDir, binFileName, extractedFolderName, extractFunction } = await getPackageInfo (
50+ version ,
51+ process . platform
52+ )
4853
4954 // Restore from cache (if found).
5055 if ( isCI ( ) ) {
5156 try {
5257 const dir = find ( name , version )
5358 if ( dir ) {
54- info ( `${ name } ${ version } was found in the cache.` )
5559 const installDir = join ( dir , extractedFolderName )
5660 const binDir = join ( installDir , binRelativeDir )
57- addPath ( binDir )
58- return { installDir, binDir }
61+ if ( existsSync ( binDir ) && existsSync ( join ( binRelativeDir , binFileName ) ) ) {
62+ info ( `${ name } ${ version } was found in the cache.` )
63+ addPath ( binDir )
64+ return { installDir, binDir }
65+ }
5966 }
6067 } catch {
6168 // fails on a local machine?
6269 }
6370 }
6471
72+ const installDir = join ( setupDir , extractedFolderName )
73+ const binDir = join ( installDir , binRelativeDir )
74+ const binFile = join ( binDir , binFileName )
75+
6576 // download ane extract the package into the installation directory.
66- if ( ! existsSync ( setupDir ) ) {
77+ if ( ! existsSync ( binDir ) || ! existsSync ( binFile ) ) {
6778 info ( `Download and extract ${ name } ${ version } ` )
6879 const downloaded = await downloadTool ( url )
6980 await extractFunction ?.( downloaded , setupDir )
7081 }
7182
72- const installDir = join ( setupDir , extractedFolderName )
73- const binDir = join ( installDir , binRelativeDir )
74-
7583 // Adding the bin dir to the path
7684 /** The directory which the tool is installed to */
7785 info ( `Add ${ binDir } to PATH` )
0 commit comments