Skip to content

Commit 91325bf

Browse files
committed
Adds skipIfExist
1 parent 7a904cc commit 91325bf

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/downloader.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function download(link: string, outPath: string, options: DownloadO
2222
if (!response.ok) {
2323
throw new Error(`Error while downloading ${name}:${link}. ${response.statusText}`);
2424
}
25-
if (options.skipIfCached) {
25+
if (options.skipIfExist) {
2626
if (await fsExist(outPath)) {
2727
return console.warn(`Archive already exists at ${outPath}. Skipping download....`);
2828
}
@@ -37,4 +37,7 @@ export async function download(link: string, outPath: string, options: DownloadO
3737
);
3838
}
3939

40-
type DownloadOptions = { name?: string; skipIfCached?: boolean };
40+
type DownloadOptions = {
41+
name?: string;
42+
skipIfExist?: boolean;
43+
};

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
export { download } from './downloader';
2+
export { extract } from './extractor';
13
export { setupQt } from './setup';

src/setup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ type SupportedOs = 'linux' | 'win32' | 'darwin';
1010
type SetupOptions = {
1111
qtDir: string;
1212
downloadLink?: string;
13+
cacheDir?: string;
1314
osType: SupportedOs;
1415
};
1516

1617
export async function setupQt(options: SetupOptions): Promise<string> {
1718
const downloadLink = options.downloadLink || metadata[options.osType];
18-
const archivePath = path.resolve(appPaths.cache, path.basename(downloadLink));
19+
const cacheDir = options.cacheDir || appPaths.cache;
20+
const archivePath = path.resolve(cacheDir, path.basename(downloadLink));
1921
const extractDir = options.qtDir;
20-
await download(downloadLink, archivePath, { name: 'Qt for Mac', skipIfCached: true });
22+
await download(downloadLink, archivePath, { name: 'Mini Qt', skipIfExist: true });
2123
await extract(archivePath, extractDir);
2224
console.log(`Mini Qt was setup successfully. QtDir: ${extractDir}`);
2325
return extractDir;

0 commit comments

Comments
 (0)