Skip to content

Commit

Permalink
[plugin] add bunx function
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Apr 10, 2024
1 parent b9c424e commit 7eb7784
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
6 changes: 5 additions & 1 deletion dagger.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"name": "bun",
"sdk": "github.com/fluentci-io/daggerverse/deno-sdk@main"
"sdk": "github.com/fluentci-io/daggerverse/deno-sdk@main",
"version": "v0.7.0",
"description": "",
"author": "Tsiry Sandratraina",
"license": "MIT"
}
2 changes: 1 addition & 1 deletion plugin/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "bun"
version = "0.1.0"
version = "0.7.0"

[lib]
crate-type = ["cdylib"]
Expand Down
26 changes: 21 additions & 5 deletions plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pub fn test(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("test")?
.pkgx()?
.with_exec(vec!["pkgx", "install", "node", "bun"])?
.with_exec(vec!["type node > /dev/null || pkgx install node"])?
.with_exec(vec!["pkgx", "install", "bun"])?
.with_exec(vec!["bun", "install"])?
.with_exec(vec!["bun", "test", &args])?
.stdout()?;
Expand All @@ -16,9 +17,10 @@ pub fn test(args: String) -> FnResult<String> {
#[plugin_fn]
pub fn build(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("test")?
.pipeline("build")?
.pkgx()?
.with_packages(vec!["node", "bun"])?
.with_exec(vec!["type node > /dev/null || pkgx install node"])?
.with_packages(vec!["bun"])?
.with_exec(vec!["bun", "install"])?
.with_exec(vec!["bun", "build", &args])?
.stdout()?;
Expand All @@ -28,11 +30,25 @@ pub fn build(args: String) -> FnResult<String> {
#[plugin_fn]
pub fn run(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("test")?
.pipeline("run")?
.pkgx()?
.with_packages(vec!["node", "bun"])?
.with_exec(vec!["type node > /dev/null || pkgx install node"])?
.with_packages(vec!["bun"])?
.with_exec(vec!["bun", "install"])?
.with_exec(vec!["bun", "run", &args])?
.stdout()?;
Ok(stdout)
}

#[plugin_fn]
pub fn bunx(args: String) -> FnResult<String> {
let stdout = dag()
.pipeline("bunx")?
.pkgx()?
.with_exec(vec!["type node > /dev/null || pkgx install node"])?
.with_packages(vec!["bun"])?
.with_exec(vec!["bun", "install"])?
.with_exec(vec!["bunx", &args])?
.stdout()?;
Ok(stdout)
}

0 comments on commit 7eb7784

Please sign in to comment.