Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Node instead of curl #58

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});