extends Node ## Parse every GDScript in the project so the engine prints any parse or type ## error, then quit. ## ## Run as a scene (not with --script) because autoload identifiers such as `Net` ## are only registered when the engine boots a real main loop; a --script run ## reports false "Identifier not found" errors for every file that uses one. ## ## godot --headless --path . res://tools/check.tscn ## ## `tools/check.sh` wraps this and owns the exit code: a script that fails to ## parse can still come back from ResourceLoader as a non-null object, so the ## engine's own stderr is the reliable signal. const SKIP_DIRS := ["res://addons", "res://.godot"] func _ready() -> void: var scripts := _collect("res://") scripts.sort() for path in scripts: ResourceLoader.load(path, "Script") print("CHECK_COMPLETE scripts=%d" % scripts.size()) get_tree().quit(0) func _collect(dir_path: String) -> Array[String]: var out: Array[String] = [] for skip in SKIP_DIRS: if dir_path.begins_with(skip): return out var dir := DirAccess.open(dir_path) if dir == null: return out dir.list_dir_begin() var entry := dir.get_next() while entry != "": if entry.begins_with("."): entry = dir.get_next() continue var full := dir_path.path_join(entry) if dir.current_is_dir(): out.append_array(_collect(full)) elif entry.ends_with(".gd"): out.append(full) entry = dir.get_next() dir.list_dir_end() return out