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 0000000..e929478 Binary files /dev/null and b/tests/shouldntContainModel1.rbxm differ