Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb committed Sep 30, 2024
1 parent 74d0081 commit 47312c3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion crates/reg_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum CompareError {
static SUPPORTED_EXTENTIONS: [&str; 7] = ["tiff", "jpeg", "jpg", "gif", "png", "bmp", "webp"];

static DEFAULT_JSON_PATH: &'static str = "./reg.json";
static DEFAULT_REPORT_PATH: &'static str = "./report.html";

fn is_supported_extension(path: &Path) -> bool {
if let Some(extension) = path.extension() {
Expand Down Expand Up @@ -103,6 +104,9 @@ pub fn run(
let expected_dir = expected_dir.as_ref();
let diff_dir = diff_dir.as_ref();
let json_path = options.json.unwrap_or_else(|| Path::new(DEFAULT_JSON_PATH));
let report = options
.report
.unwrap_or_else(|| Path::new(DEFAULT_REPORT_PATH));

let detected = find_images(&expected_dir, &actual_dir);

Expand Down Expand Up @@ -171,7 +175,7 @@ pub fn run(
deleted: detected.deleted,
actual: detected.actual,
expected: detected.expected,
report: options.report,
report,
differences,
json: json_path,
actual_dir,
Expand Down
7 changes: 3 additions & 4 deletions crates/reg_core/src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) struct ReportInput<'a> {
pub(crate) actual_dir: &'a Path,
pub(crate) expected_dir: &'a Path,
pub(crate) diff_dir: &'a Path,
pub(crate) report: Option<&'a Path>,
pub(crate) report: &'a Path,
// junitReport: string,
// extendedErrors: boolean,
pub(crate) url_prefix: Option<url::Url>,
Expand Down Expand Up @@ -146,7 +146,8 @@ pub fn create_reports(input: ReportInput) -> Reports {
diff_dir: create_dir_for_json_report(input.json, input.diff_dir, input.url_prefix.clone()),
};

let html_report = if let Some(report) = input.report {
let html_report = {
let report = input.report;
let template = include_str!("../../../template/template.html");
let js = include_str!("../../../report/ui/dist/report.js");
let css = include_str!("../../../report/ui/dist/style.css");
Expand Down Expand Up @@ -207,8 +208,6 @@ pub fn create_reports(input: ReportInput) -> Reports {
.render_data(&mut html, &data)
.expect("should render report.");
Some(html.into())
} else {
None
};

Reports {
Expand Down
2 changes: 1 addition & 1 deletion js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const compare = (input: CompareInput): EventEmitter => {
actualDir,
expectedDir,
diffDir,
...Object.entries(rest).flatMap(([k, v]) => [`--${k}`, String(v)]),
...Object.entries(rest).flatMap(([k, v]) => (v == null ? [] : [`--${k}`, String(v)])),
];
return run(args);
};
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reg-cli",
"version": "0.0.0-experimental-wasm9",
"version": "0.0.0-experimental-wasm10",
"description": "",
"type": "module",
"start": "node ./dist/cli.mjs",
Expand Down
Binary file modified js/reg.wasm
Binary file not shown.

0 comments on commit 47312c3

Please sign in to comment.