Skip to content

Commit 77f910e

Browse files
committed
add dstFileName option to downloadAndExtractFile()
1 parent 31c339a commit 77f910e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/cubejs-backend-shared/src/http-utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ type DownloadAndExtractFile = {
6767
showProgress: boolean;
6868
cwd: string;
6969
noExtract?: boolean;
70+
dstFileName?: string;
7071
};
7172

72-
export async function downloadAndExtractFile(url: string, { cwd, noExtract }: DownloadAndExtractFile) {
73+
export async function downloadAndExtractFile(url: string, { cwd, noExtract, dstFileName }: DownloadAndExtractFile) {
7374
const request = new Request(url, {
7475
headers: new Headers({
7576
'Content-Type': 'application/octet-stream',
@@ -101,7 +102,11 @@ export async function downloadAndExtractFile(url: string, { cwd, noExtract }: Do
101102
});
102103

103104
if (noExtract) {
104-
fs.copyFileSync(savedFilePath, cwd);
105+
if (dstFileName) {
106+
fs.copyFileSync(savedFilePath, path.resolve(path.join(cwd, dstFileName)));
107+
} else {
108+
fs.copyFileSync(savedFilePath, cwd);
109+
}
105110
} else {
106111
await decompress(savedFilePath, cwd);
107112
}

packages/cubejs-databricks-jdbc-driver/src/installer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export async function downloadJDBCDriver(): Promise<string | null> {
3434
showProgress: true,
3535
cwd: path.resolve(path.join(__dirname, '..', 'download')),
3636
noExtract: true,
37+
dstFileName: 'databricks-jdbc-1.0.2-oss.jar',
3738
}
3839
);
3940

0 commit comments

Comments
 (0)