Skip to content

Commit f17c71c

Browse files
committed
Delete mpm file if it exists
1 parent 2b689a9 commit f17c71c

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/mpm.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,25 @@ export async function setup(platform: string, architecture: string): Promise<str
3838
return Promise.reject(Error("Unable to find runner temporary directory."));
3939
}
4040
let mpmDest = path.join(runner_temp, `mpm${ext}`);
41-
if (!fs.existsSync(mpmDest)){
42-
let mpm: string = await tc.downloadTool(mpmUrl, mpmDest);
4341

44-
if (platform !== "win32") {
45-
const exitCode = await exec.exec(`chmod +x "${mpm}"`);
46-
if (exitCode !== 0) {
47-
return Promise.reject(Error("Unable to set up mpm."));
48-
}
42+
// Delete mpm file if it exists
43+
if (fs.existsSync(mpmDest)) {
44+
try {
45+
fs.unlinkSync(mpmDest);
46+
} catch (err) {
47+
return Promise.reject(Error(`Failed to delete existing mpm file: ${err}`));
4948
}
50-
51-
return mpm;
5249
}
53-
else{
54-
return mpmDest
50+
51+
let mpm: string = await tc.downloadTool(mpmUrl, mpmDest);
52+
53+
if (platform !== "win32") {
54+
const exitCode = await exec.exec(`chmod +x "${mpm}"`);
55+
if (exitCode !== 0) {
56+
return Promise.reject(Error("Unable to set up mpm."));
57+
}
5558
}
59+
return mpm
5660
}
5761

5862
export async function install(mpmPath: string, release: matlab.Release, products: string[], destination: string) {

0 commit comments

Comments
 (0)