More code simplification
This commit is contained in:
parent
fbc21592af
commit
ab304e7d38
1 changed files with 1 additions and 4 deletions
|
|
@ -229,7 +229,6 @@ impl StaticFiles {
|
||||||
pub fn write_files(self, destination: &Path) -> Result<ResourceHelper> {
|
pub fn write_files(self, destination: &Path) -> Result<ResourceHelper> {
|
||||||
use crate::utils::fs::write_file;
|
use crate::utils::fs::write_file;
|
||||||
use regex::bytes::{Captures, Regex};
|
use regex::bytes::{Captures, Regex};
|
||||||
use std::io::Read;
|
|
||||||
// The `{{ resource "name" }}` directive in static resources look like
|
// The `{{ resource "name" }}` directive in static resources look like
|
||||||
// handlebars syntax, even if they technically aren't.
|
// handlebars syntax, even if they technically aren't.
|
||||||
static RESOURCE: Lazy<Regex> =
|
static RESOURCE: Lazy<Regex> =
|
||||||
|
|
@ -278,9 +277,7 @@ impl StaticFiles {
|
||||||
.with_context(|| format!("Unable to create {}", parent.display()))?;
|
.with_context(|| format!("Unable to create {}", parent.display()))?;
|
||||||
}
|
}
|
||||||
if filename.ends_with(".css") || filename.ends_with(".js") {
|
if filename.ends_with(".css") || filename.ends_with(".js") {
|
||||||
let mut file = File::open(input_location)?;
|
let data = fs::read(input_location)?;
|
||||||
let mut data = Vec::new();
|
|
||||||
file.read_to_end(&mut data)?;
|
|
||||||
let data = replace_all(&self.hash_map, &data, filename);
|
let data = replace_all(&self.hash_map, &data, filename);
|
||||||
write_file(destination, filename, &data)?;
|
write_file(destination, filename, &data)?;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue