diff options
author | davidot <davidot@serenityos.org> | 2022-01-17 18:47:32 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-22 01:21:18 +0000 |
commit | 0e56dac51e294cd1195a2bae9793aa0554468d29 (patch) | |
tree | f0028b753e1558ee50500395197d908531cf8f38 | |
parent | 2d4b345bb1a54ecf34d3c088e3a45d61d23a9e57 (diff) | |
download | serenity-0e56dac51e294cd1195a2bae9793aa0554468d29.zip |
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.
-rw-r--r-- | Userland/Utilities/js.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index ea486e09b9..c77c563f80 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -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; } |