Skip to content

Commit ecd5cdd

Browse files
committed
Init detection of old consts
1 parent c882328 commit ecd5cdd

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

src/actions.rs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,20 +323,45 @@ pub fn execute_prime(command: &str, args: Vec<String>, quiet: bool) -> ExitStatu
323323

324324
pub fn parse_all(root: &Path) {
325325
let parser = config::get().software.luac;
326+
let scripts = files::get_file_tree_of_type(root, "lua");
326327

327328
if !command_exists(&parser) {
328-
print_warn(format!("'{}' not found. Skipping parse.", &parser));
329+
print_warn(format!("'{}' not found. Skipping luac parse.", &parser));
329330
return;
330331
}
331332

332-
print_step("Parsing Lua scripts...");
333+
print_step("Checking validity of Lua scripts...");
333334

334-
let scripts = files::get_file_tree_of_type(root, "lua");
335-
336-
for script in scripts {
335+
for script in &scripts {
337336
execute(&parser, vec!["-p".to_string(), script.to_str().unwrap().to_string()], true);
338337
}
339338

339+
print_step("Checking for deprecated features...");
340+
341+
let env_repl = get_env_replacement_map();
342+
343+
for script in &scripts {
344+
let mut file = files::open(&script);
345+
let mut buf = String::new();
346+
let script_path_str = script.to_str().unwrap();
347+
348+
file.read_to_string(&mut buf).unwrap_or_else(|err| {
349+
exit_err(format!("Failed to read buffer of {}: {}", script_path_str, err))
350+
});
351+
352+
let lines: Vec<&str> = buf.lines().collect();
353+
354+
for i in 0..lines.len() {
355+
let line = lines[i].to_string();
356+
357+
for (old, new) in &env_repl {
358+
if line.contains(old) {
359+
print_warn(format!("{}:{} Use '{}' instead of {}", script_path_str, i + 1, new, old));
360+
}
361+
}
362+
}
363+
}
364+
340365
print_success_verbose(
341366
&get_command_line_settings(),
342367
"Parsing successful"

0 commit comments

Comments
 (0)