Skip to content

Commit

Permalink
turn warn into debug (#296)
Browse files Browse the repository at this point in the history
* turn warn into debug

* Update asset.jl
  • Loading branch information
SimonDanisch authored Feb 18, 2025
1 parent 8d36501 commit d27f240
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/asset-serving/asset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,15 @@ end


function generate_bundle_file(file, bundle_file)
# If it's an URL we assume it's bundled if the bundle file exists,
# since the content of the url should not change (use versions in URLs!)
isfile(bundle_file) && is_online(file) && return bundle_file
if isfile(file) || is_online(file)
if needs_bundling(file, bundle_file)
bundled, err = deno_bundle(file, bundle_file)
if !bundled
if isfile(bundle_file)
@warn "Failed to bundle $file: $err"
@debug "Failed to bundle $file: $err"
else
error("Failed to bundle $file: $err")
end
Expand Down Expand Up @@ -254,7 +257,7 @@ function bundle_path(asset::Asset)
return asset.bundle_file
end

last_modified(path::Path) = last_modified(Bonito.getroot(path))
last_modified(path::Path) = last_modified(getroot(path))
function last_modified(path::String)
Dates.unix2datetime(Base.Filesystem.mtime(path))
end
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Needs to be done before loading Bonito
include("test-bundles.jl")
using Bonito
# ENV["JULIA_DEBUG"] = Bonito

using Deno_jll
using Hyperscript, Markdown, Test, RelocatableFolders
using Observables
Expand Down
17 changes: 17 additions & 0 deletions test/test-bundles.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Dates, Test

function last_modified(path::String)
return Dates.unix2datetime(Base.Filesystem.mtime(path))
end

function needs_bundling(path, bundled)
!isfile(bundled) && return true
# If bundled happen after last modification of asset
return last_modified(path) > last_modified(bundled)
end

path = joinpath(@__DIR__, "..", "js_dependencies")
bundles(x) = (joinpath(path, x), joinpath(path, replace(x, ".js" => ".bundled.js")))
@test !needs_bundling(bundles("Bonito.js")...)
@test !needs_bundling(bundles("Websocket.js")...)
@test !needs_bundling(bundles("nouislider.min.js")...)

0 comments on commit d27f240

Please sign in to comment.