mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
js: Display a warning if multiple files are given
Also instead of making a frankenstein path with all the paths combined just take the first one, this is needed for resolving modules.
This commit is contained in:
parent
2d4b345bb1
commit
0e56dac51e
Notes:
sideshowbarker
2024-07-17 20:28:00 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/0e56dac51e2 Pull-request: https://github.com/SerenityOS/serenity/pull/11957 Reviewed-by: https://github.com/emanuele6 Reviewed-by: https://github.com/linusg
1 changed files with 5 additions and 3 deletions
|
@ -1547,6 +1547,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
sigint_handler();
|
||||
});
|
||||
|
||||
if (script_paths.size() > 1)
|
||||
warnln("Warning: Multiple files supplied, this will concatenate the sources and resolve modules as if it was the first file");
|
||||
|
||||
StringBuilder builder;
|
||||
for (auto& path : script_paths) {
|
||||
auto file = TRY(Core::File::open(path, Core::OpenMode::ReadOnly));
|
||||
|
@ -1555,10 +1558,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
builder.append(source);
|
||||
}
|
||||
|
||||
StringBuilder source_name_builder;
|
||||
source_name_builder.join(", ", script_paths);
|
||||
// We resolve modules as if it is the first file
|
||||
|
||||
if (!parse_and_run(*interpreter, builder.string_view(), source_name_builder.string_view()))
|
||||
if (!parse_and_run(*interpreter, builder.string_view(), script_paths[0]))
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue