Skip to content
This repository was archived by the owner on May 20, 2020. It is now read-only.

Whitelist files in build.rs #112

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ git = "http://github.com/steveklabnik/rls-analysis"
error-chain = "=0.11.0-rc.2"
quote = "0.3"
syn = "0.11"
walkdir = "1.0.7"
glob = "0.2.11"

[dev-dependencies]
error-chain = "=0.11.0-rc.2"
Expand Down
32 changes: 21 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate error_chain;
#[macro_use]
extern crate quote;
extern crate syn;
extern crate walkdir;
extern crate glob;

use std::env;
use std::fmt;
Expand All @@ -17,12 +17,13 @@ use std::process::exit;
use std::thread;

use quote::Ident;
use walkdir::WalkDir;
use glob::glob;

error_chain! {
foreign_links {
Io(::std::io::Error);
WalkDir(::walkdir::Error);
PatternError(::glob::PatternError);
GlobError(::glob::GlobError);
}
}

Expand Down Expand Up @@ -65,14 +66,23 @@ fn main() {
/// Start the recursion from the top level of the frontend's dist folder
fn acquire_assets() -> Result<Vec<Asset>> {
let mut output: Vec<Asset> = Vec::new();

for entry in WalkDir::new(DIST).into_iter() {
let entry = entry?;
if entry.metadata()?.is_file() {
output.push(Asset {
// If the directory isn't valid this wouldn't have worked.
path: String::from(entry.path().to_str().unwrap()).replace("\\", "/"),
});
let whitelist = vec![
"assets/**",
"crossdomain.xml",
"ember-fetch/**",
"index.html",
"robots.txt",
];

for w in whitelist {
for entry in glob(&format!("{}{}", DIST, w))? {
let path = entry?;
if path.is_file() {
output.push(Asset {
// If the directory isn't valid this wouldn't have worked.
path: String::from(path.to_str().unwrap()).replace("\\", "/"),
});
}
}
}

Expand Down