devbox

Crates.iodevbox
lib.rsdevbox
version0.1.1
sourcesrc
created_at2020-05-15 20:02:59.740633
updated_at2020-12-25 03:51:06.392883
descriptionDeveloper toolbox for building and testing
homepage
repositoryhttps://github.com/peterkozelj/devbox
max_upload_size
id242148
size10,683
Peter Koželj (peterkozelj)

documentation

README

Crates.io MIT licensed

devbox

A collection of small build related librarires intended to be used as dev-dependencies

Install

To get started, add the following to Cargo.toml under dev-dependencies:

[dev-dependencies]
devbox = { version = "0.1" }

Test macro

Adds parametrization capabilty to #[test] via #[args] attribute macro.

#[args(
    char_a: 'a';
    char_b: 'b' ! "unexpected character";
)]
#[test]
fn parametrized_test_for(character:_) {
    assert_eq!('a', character, "unexpected character");
}

Check #[args] attribute for full example and usage specification.

Build srcipt

Small utility library for easier file manipulation and external tool invocation in Rust build sripts (build.rs) that avoids rebuilding up-to-date build artifacts.


pub fn main() {

    let build = Build::new();
    let websrc = build.manifest_dir().dir("webapp");
    let webwrk = build.out_dir().dir("webapp_build");
    let webwrk_pkg = webwrk.file("package.json");
    let webwrk_pkl = webwrk.file("package-lock.json");

    for unit in websrc.content("*") {
        unit.link_from_inside(&webwrk);
    }

    let npm = Cmd::new("npm").arg("--prefix").arg(webwrk.path());

    webwrk.dir("node_modules").mk_from("Install WebApp node packages", &webwrk_pkg + &webwrk_pkl, ||{
        npm.clone().arg("install").run();
        webwrk.dir("node_modules").touch();
    });

    webwrk.dir("dist").mk_from("Build WebApp using webpack", &webwrk.content("**"), || {
        npm.clone().arg("run").arg("build").run();
        webwrk.dir("dist").touch();
    });
}

Check build module for fully working example and usage specification.

License

Licensed under MIT license (LICENSE or https://opensource.org/licenses/MIT)

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Devbox by you, shall be licensed as MIT, without any additional terms or conditions.

Commit count: 27

cargo fmt