Skip to content

Commit 964c90c

Browse files
committed
add delete zip file after extracted
1 parent 1d611c9 commit 964c90c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/main/osinstaller/CxInstaller.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as tar from 'tar';
55
import axios from 'axios';
66
import * as unzipper from 'unzipper';
77
import {Semaphore} from 'async-mutex';
8-
import * as os from "os";
98
import {logger} from "../wrapper/loggerConfig";
109
import {finished} from 'stream/promises';
1110

@@ -56,12 +55,21 @@ export class CxInstaller {
5655
return;
5756
}
5857
const url = await this.getDownloadURL();
59-
const zipPath = path.join(os.tmpdir(), `ast-cli.${this.platform === 'win32' ? 'zip' : 'tar.gz'}`);
58+
const zipPath = path.join(this.resourceDirPath, this.getCompressFolderName());
6059

6160
await this.downloadFile(url, zipPath);
6261
logger.info('Downloaded CLI to:', zipPath);
6362

6463
await this.extractArchive(zipPath, this.resourceDirPath);
64+
65+
fs.unlink(zipPath, (err) => {
66+
if (err) {
67+
logger.error('Error deleting the file:', err);
68+
} else {
69+
logger.info('File deleted successfully!');
70+
}
71+
});
72+
6573
fs.chmodSync(this.getExecutablePath(), 0o755);
6674
logger.info('Extracted CLI to:', this.resourceDirPath);
6775
} catch (error) {
@@ -109,4 +117,8 @@ export class CxInstaller {
109117
return this.cliDefaultVersion;
110118
}
111119
}
120+
121+
getCompressFolderName(): string {
122+
return `ast-cli.${this.platform === 'win32' ? 'zip' : 'tar.gz'}`;
123+
}
112124
}

0 commit comments

Comments
 (0)