Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
prohibit upload of directory named node_modules (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabbifish authored Oct 21, 2019
1 parent e543b82 commit 80c9bfc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/commands/kv/bucket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,24 @@ fn directory_keys_only(target: &Target, directory: &Path) -> Result<Vec<String>,
Ok(upload_vec)
}

const REQUIRED_IGNORE_FILES: &[&str] = &["node_modules"];
const NODE_MODULES: &str = "node_modules";

fn get_dir_iterator(target: &Target, directory: &Path) -> Result<Walk, failure::Error> {
// The directory provided should never be node_modules!
match directory.file_name() {
Some(name) => {
if name == NODE_MODULES {
failure::bail!("Your directory of files to upload cannot be named node_modules.");
}
}
_ => (),
}

let ignore = build_ignore(target, directory)?;
Ok(WalkBuilder::new(directory).overrides(ignore).build())
}

const REQUIRED_IGNORE_FILES: &[&str] = &["node_modules"];

fn build_ignore(target: &Target, directory: &Path) -> Result<Override, failure::Error> {
let mut required_override = OverrideBuilder::new(directory);
// First include files that must be ignored.
Expand Down

0 comments on commit 80c9bfc

Please sign in to comment.