MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add support for resolving module files in directories

+15 -1
+1 -1
meson.build
··· 75 75 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 76 76 77 77 version_conf = configuration_data() 78 - version_conf.set('ANT_VERSION', '0.2.0.5') 78 + version_conf.set('ANT_VERSION', '0.2.0.6') 79 79 version_conf.set('ANT_GIT_HASH', git_hash) 80 80 version_conf.set('ANT_BUILD_DATE', build_date) 81 81
+14
src/main.c
··· 3 3 #include <string.h> 4 4 #include <libgen.h> 5 5 #include <unistd.h> 6 + #include <sys/stat.h> 6 7 #include <argtable3.h> 7 8 8 9 #include "ant.h" ··· 223 224 224 225 if (eval->count > 0) eval_code(js, eval, print); 225 226 else if (repl_mode) ant_repl_run(); else { 227 + struct stat path_stat; 228 + char *resolved_file = NULL; 229 + 230 + if (stat(module_file, &path_stat) == 0 && S_ISDIR(path_stat.st_mode)) { 231 + size_t len = strlen(module_file); 232 + int has_slash = (len > 0 && module_file[len - 1] == '/'); 233 + resolved_file = malloc(len + 10 + (has_slash ? 0 : 1)); 234 + sprintf(resolved_file, "%s%sindex.js", module_file, has_slash ? "" : "/"); 235 + module_file = resolved_file; 236 + } 237 + 226 238 js_result = execute_module(js, module_file); 227 239 js_run_event_loop(js); 240 + 241 + if (resolved_file) free(resolved_file); 228 242 } 229 243 230 244 if (dump) js_dump(js);