Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/script-skip-ignored-dirs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@googleworkspace/cli": patch
---

Skip ignored directories while collecting files for `gws script +push`.
21 changes: 14 additions & 7 deletions crates/google-workspace-cli/src/helpers/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ fn visit_dirs(dir: &Path, files: &mut Vec<serde_json::Value>) -> Result<(), GwsE
let entry = entry.context("Failed to read entry")?;
let path = entry.path();
if path.is_dir() {
let dirname = path.file_name().and_then(|s| s.to_str()).unwrap_or("");
if dirname.starts_with('.') || dirname == "node_modules" {
continue;
}
visit_dirs(&path, files)?;
} else if let Some(file_obj) = process_file(&path)? {
files.push(file_obj);
Expand All @@ -169,13 +173,8 @@ fn process_file(path: &Path) -> Result<Option<serde_json::Value>, GwsError> {
filename.trim_end_matches(".js").trim_end_matches(".gs"),
),
"html" => ("HTML", filename.trim_end_matches(".html")),
"json" => {
if filename == "appsscript.json" {
("JSON", "appsscript")
} else {
return Ok(None);
}
}
"json" if filename == "appsscript.json" => ("JSON", "appsscript"),
"json" => return Ok(None),
_ => return Ok(None),
};

Expand Down Expand Up @@ -277,6 +276,14 @@ mod tests {
let f3 = dir.path().join("ignore.txt");
File::create(&f3).unwrap();

let hidden = dir.path().join(".hidden");
fs::create_dir(&hidden).unwrap();
File::create(hidden.join("secret.gs")).unwrap();

let node_modules = dir.path().join("node_modules");
fs::create_dir(&node_modules).unwrap();
File::create(node_modules.join("dep.gs")).unwrap();

let mut files = Vec::new();
visit_dirs(dir.path(), &mut files).unwrap();

Expand Down
Loading