File tree Expand file tree Collapse file tree 2 files changed +50
-2
lines changed
Expand file tree Collapse file tree 2 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -179,9 +179,57 @@ static bool reportModuleResult(Luau::Frontend& frontend, const Luau::ModuleName&
179179 return cr->errors .empty () && cr->lintResult .errors .empty ();
180180}
181181
182+ static std::string getExtension (const std::string& path)
183+ {
184+ size_t dot = path.find_last_of (" .\\ /" );
185+
186+ if (dot == std::string::npos || path[dot] != ' .' )
187+ return " " ;
188+
189+ return path.substr (dot);
190+ }
182191
183- int typecheck (const std::vector<std::string> sourceFiles )
192+ std::vector<std::string> processSourceFiles (const std::vector<std::string>& sourceFilesInput )
184193{
194+ std::vector<std::string> files;
195+
196+ for (const auto & path :sourceFilesInput)
197+ {
198+ std::string normalized = normalizePath (path);
199+
200+ if (isDirectory (normalized))
201+ {
202+ traverseDirectory (
203+ normalized,
204+ [&](const std::string& name)
205+ {
206+ std::string ext = getExtension (name);
207+
208+ if (ext == " .lua" || ext == " .luau" )
209+ files.push_back (name);
210+ }
211+ );
212+ }
213+ else
214+ {
215+ files.push_back (normalized);
216+ }
217+ }
218+
219+
220+ return files;
221+ }
222+
223+ int typecheck (const std::vector<std::string>& sourceFilesInput)
224+ {
225+ std::vector<std::string> sourceFiles = processSourceFiles (sourceFilesInput);
226+
227+ if (sourceFiles.empty ())
228+ {
229+ fprintf (stderr, " Error: lute --check expects a file to type check.\n\n " );
230+ return 1 ;
231+ }
232+
185233 Luau::Mode mode = Luau::Mode::Strict;
186234 bool annotate = true ;
187235 std::string basePath = " " ;
Original file line number Diff line number Diff line change 44#include " Luau/Frontend.h"
55#include " Luau/FileUtils.h"
66
7- int typecheck (const std::vector<std::string> sourceFiles);
7+ int typecheck (const std::vector<std::string>& sourceFiles);
You can’t perform that action at this time.
0 commit comments