From e6dbf0e3c7d076e0ff2cfa1e1db9eecca509fb13 Mon Sep 17 00:00:00 2001 From: filoxenace Date: Mon, 22 Sep 2025 15:55:24 -0400 Subject: [PATCH] Fix scan functionality --- detector.luau | 29 +++++++++++++++++++++++++---- tests/shouldntContainModel1.rbxm | Bin 0 -> 3973 bytes 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 tests/shouldntContainModel1.rbxm diff --git a/detector.luau b/detector.luau index 157e24f..993aaac 100644 --- a/detector.luau +++ b/detector.luau @@ -1,16 +1,27 @@ local process = require("@lune/process") local fs = require("@lune/fs") local roblox = require("@lune/roblox") +local stdio = require("@lune/stdio") -local args = process.args() +local args = process.args + +if #args < 1 then + stdio.write(stdio.color("red")) + stdio.write("Error: Please provide a file path as an argument.") + stdio.write(stdio.color("reset")) + process.exit(1) +end local fileFromArgs: string = fs.readFile(args[1]) -function scanForWorkspace(model: Model): boolean - for _index, child in model:GetDescendants() do +function scanForWorkspace(model: {Instance}): boolean + for _index, child in ipairs(model) do if child:IsA("Workspace") then return true + else + local children = child:GetChildren() + scanForWorkspace(children) end end return false @@ -21,4 +32,14 @@ function containsWorkspace(fileContents: string): boolean return scanForWorkspace(instances) end -containsWorkspace(fileFromArgs) \ No newline at end of file +function formatResult(result: boolean, fileName: string): string + if result then + return `File {fileName} contains a Workspace instance.` + else + return `File {fileName} does not contain a Workspace instance.` + end +end + +local result = formatResult(containsWorkspace(fileFromArgs), args[1]) + +print(result) \ No newline at end of file diff --git a/tests/shouldntContainModel1.rbxm b/tests/shouldntContainModel1.rbxm new file mode 100644 index 0000000000000000000000000000000000000000..e929478ab0becc48fa6cd95c5e19e7a2dffd1563 GIT binary patch literal 3973 zcma)9&2Jl35T9MU`EcVBhcu;4OP5d}sba?=O&YbNrAeDMQrcQc`hmFQW&K<)-R!P* z*Q7y$m~uc|5FEHiLPFvO|3QVs4G9Ei1nQN`Hb_XE%>33~$8I(eKV{;#`)207nKvJA z-*W9W(|+{IXSHM`b1j^K zwt{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