Skip to content

Commit

Permalink
Use Node instead of curl (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
samestep authored Jul 18, 2023
1 parent 63a97be commit 46df0b6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

Make sure to have these tools installed:

- [curl][]
- [Git][]
- [Make][]
- [Rust][]
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions fetch.js
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 46df0b6

Please sign in to comment.