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

Implement Brioche.glob global function #40

Merged
merged 1 commit into from
May 26, 2024

Conversation

kylewlacy
Copy link
Member

@kylewlacy kylewlacy commented May 26, 2024

This PR adds support for a new Brioche.glob global function. The core idea is very similar to Brioche.includeFile / Brioche.includeDirectory (#34 / #35): the project analyzer recognizes calls to Brioche.glob, looks at the local filesystem, then builds a recipe that can be retrieved with a special op from the JS side. See brioche-dev/brioche-packages#10 for the implementation in std

Here's an example:

// myproject/
//   project.bri
//   Cargo.toml
//   Cargo.lock
//   src/
//     main.rs
import * as std from "std";

// Returns a directory artifact with these entries:
//   Cargo.toml
//   Cargo.lock
//   src/
//     main.rs
export default async () => {
  return Brioche.glob("Cargo.lock", "Cargo.toml", "src");
};

Glob patterns are matched using the walkdir and globset crates (glob patterns are built with the options literal_separator, backslash_escape, and empty_alternates)

@kylewlacy kylewlacy merged commit 68cf1cd into main May 26, 2024
7 checks passed
@kylewlacy kylewlacy deleted the implement-brioche-glob-static-method branch May 26, 2024 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant