keycloak_theme/src/bin/tools/downloadAndUnzip.ts

22 lines
500 B
TypeScript
Raw Normal View History

2021-02-28 18:40:57 +01:00
import { basename as pathBasename } from "path";
import child_process from "child_process";
import fs from "fs";
export function downloadAndUnzip(
params: {
url: string;
destDirPath: string;
}
) {
const { url, destDirPath } = params;
fs.mkdirSync(destDirPath, { "recursive": true });
[
`wget ${url}`,
...["unzip", "rm"].map(prg => `${prg} ${pathBasename(url)}`),
].forEach(cmd => child_process.execSync(cmd, { "cwd": destDirPath }));
}