Last active
February 14, 2024 10:26
-
-
Save mirismaili/4de8575ff0697a433dfb865e0cdccba1 to your computer and use it in GitHub Desktop.
Fast download>--pipe-->extract using node.js. For `tar` and `.tar.gz` files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Download and extract `.tar.gz` file using node.js | |
* | |
* Created on 1400/2/7 (2021/4/27). | |
* @author {@link https://mirismaili.github.io S. Mahdi Mir-Ismaili} | |
*/ | |
import http from 'http' | |
import https from 'https' | |
import tar from 'tar' | |
const url = new URL(process.argv[2]) // 'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.2-97d11b01.tar.gz' | |
const agent = url.protocol === 'https:' ? https : http | |
// noinspection JSCheckFunctionSignatures | |
agent.get(url, res => res.pipe(tar.x())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment