diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f926a5d..390e35e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,6 @@ Make sure to have these tools installed: -- [curl][] - [Git][] - [Make][] - [Rust][] @@ -97,7 +96,6 @@ make vscode Then `packages/vscode` will contain a `*.vsix` file that you can install in VS Code by right-clicking it and clicking the **Install Extension VSIX** button. -[curl]: https://curl.se/ [git]: https://git-scm.com/downloads [make]: https://en.wikipedia.org/wiki/Make_(software) [node.js]: https://nodejs.org/en/download diff --git a/Makefile b/Makefile index c80552c..078bccb 100644 --- a/Makefile +++ b/Makefile @@ -74,11 +74,11 @@ site: site-deps # fetch encircled icon packages/vscode/encircled-rose.png: - curl -O --output-dir packages/vscode https://github.com/rose-lang/rose-icons/raw/efcc218832d65970a47bed597ee11cecd3d1cc3c/png/encircled-rose.png + node fetch.js https://github.com/rose-lang/rose-icons/raw/efcc218832d65970a47bed597ee11cecd3d1cc3c/png/encircled-rose.png $@ # fetch plain icon packages/vscode/plain-rose.png: - curl -O --output-dir packages/vscode https://github.com/rose-lang/rose-icons/raw/efcc218832d65970a47bed597ee11cecd3d1cc3c/png/plain-rose.png + node fetch.js https://github.com/rose-lang/rose-icons/raw/efcc218832d65970a47bed597ee11cecd3d1cc3c/png/plain-rose.png $@ # build vscode: yarn packages/vscode/encircled-rose.png packages/vscode/plain-rose.png diff --git a/fetch.js b/fetch.js new file mode 100644 index 0000000..af718ca --- /dev/null +++ b/fetch.js @@ -0,0 +1,24 @@ +import { createWriteStream } from "fs"; +import https from "https"; +import { pipeline } from "stream/promises"; +import { fileURLToPath } from "url"; + +// extract command line arguments +const [fileUrl, outputPath] = process.argv.slice(2); + +https + .get(fileUrl, async (response) => { + try { + await pipeline( + response, + createWriteStream(fileURLToPath(new URL(outputPath, import.meta.url))) + ); + } catch (error) { + console.error(`Error fetching resource: ${error}`); + process.exit(1); + } + }) + .on("error", (error) => { + console.error(`Error: ${error}`); + process.exit(1); + });