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

feat(bat): add autoUpdate function to fetch latest version from GitHub #222

Merged
merged 1 commit into from
Jan 30, 2025
Merged
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
18 changes: 18 additions & 0 deletions packages/bat/project.bri
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as std from "std";
import nushell from "nushell";
import { cargoBuild } from "rust";
import { gitCheckout } from "git";

Expand Down Expand Up @@ -34,3 +35,20 @@ export async function test() {

return script;
}

export function autoUpdate() {
const src = std.file(std.indoc`
let version = http get https://api.github.com/repos/sharkdp/bat/releases/latest
| get tag_name
| str substring 1..
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was necessary to remove the 'v' behind the actual package version.


$env.project | from json | update version $version | to json
`);

return std.withRunnable(std.directory(), {
command: "nu",
args: [src],
env: { project: JSON.stringify(project) },
dependencies: [nushell()],
});
}