aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/yue.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/yue.cpp b/src/yue.cpp
index f48d14b..ee4eb38 100644
--- a/src/yue.cpp
+++ b/src/yue.cpp
@@ -201,10 +201,7 @@ static std::string compileFile(const fs::path& file, yue::YueConfig conf, const
201 conf.module = modulePath.string(); 201 conf.module = modulePath.string();
202 if (!workPath.empty()) { 202 if (!workPath.empty()) {
203 auto it = conf.options.find("path"); 203 auto it = conf.options.find("path");
204 if (it != conf.options.end()) { 204 if (it == conf.options.end()) {
205 it->second += ';';
206 it->second += (workPath / "?.lua"sv).string();
207 } else {
208 conf.options["path"] = (workPath / "?.lua"sv).string(); 205 conf.options["path"] = (workPath / "?.lua"sv).string();
209 } 206 }
210 } 207 }
@@ -855,6 +852,7 @@ int main(int narg, const char** args) {
855 std::list<std::future<std::tuple<int, std::string, std::string>>> results; 852 std::list<std::future<std::tuple<int, std::string, std::string>>> results;
856 for (const auto& file : files) { 853 for (const auto& file : files) {
857 auto task = async<std::tuple<int, std::string, std::string>>([=]() { 854 auto task = async<std::tuple<int, std::string, std::string>>([=]() {
855 try {
858 std::ifstream input(file.first, std::ios::in); 856 std::ifstream input(file.first, std::ios::in);
859 if (input) { 857 if (input) {
860 std::string s( 858 std::string s(
@@ -864,10 +862,7 @@ int main(int narg, const char** args) {
864 conf.module = file.first; 862 conf.module = file.first;
865 if (!workPath.empty()) { 863 if (!workPath.empty()) {
866 auto it = conf.options.find("path"); 864 auto it = conf.options.find("path");
867 if (it != conf.options.end()) { 865 if (it == conf.options.end()) {
868 it->second += ';';
869 it->second += (fs::path(workPath) / "?.lua"sv).string();
870 } else {
871 conf.options["path"] = (fs::path(workPath) / "?.lua"sv).string(); 866 conf.options["path"] = (fs::path(workPath) / "?.lua"sv).string();
872 } 867 }
873 } 868 }
@@ -947,6 +942,15 @@ int main(int narg, const char** args) {
947 } else { 942 } else {
948 return std::tuple{1, std::string(), "Failed to read file: "s + file.first + '\n'}; 943 return std::tuple{1, std::string(), "Failed to read file: "s + file.first + '\n'};
949 } 944 }
945 } catch (const std::length_error& e) {
946 std::ostringstream buf;
947 buf << "std::length_error: " << e.what() << " for file: " << file.first << '\n';
948 return std::tuple{1, std::string(), buf.str()};
949 } catch (const std::exception& e) {
950 std::ostringstream buf;
951 buf << "Exception: " << e.what() << " for file: " << file.first << '\n';
952 return std::tuple{1, std::string(), buf.str()};
953 }
950 }); 954 });
951 results.push_back(std::move(task)); 955 results.push_back(std::move(task));
952 } 956 }