History

js: require: directory-scripts: first look at <dir>/modules/

Also, add the function mp.get_script_directory() to let scripts know if they're loaded as a directory and where.

Avi Halachmi (:avih) committed 6 years ago

Commit 756960b1 parent 68a1b474 files · +16 −1Browse files

Showing the changes to player/javascript (1 of 4 files). Show all

Unified · Split

player/javascript/defaults.js+3−0
@@ -463,6 +463,8 @@ function process_timers() { · 462 unmodified lines
463463 *********************************************************************/
464464
465465 mp.module_paths = []; // global modules search paths
466+if (mp.script_path !== undefined) // loaded as a directory
467+ mp.module_paths.push(mp.utils.join_path(mp.script_path, "modules"));
466468
467469 // Internal meta top-dirs. Users should not rely on these names.
468470 var MODULES_META = "~~modules",
@@ -645,6 +647,7 @@ mp.options = { read_options: read_options }; · 176 unmodified lines
645647 g.print = mp.msg.info; // convenient alias
646648 mp.get_script_name = function() { return mp.script_name };
647649 mp.get_script_file = function() { return mp.script_file };
650+mp.get_script_directory = function() { return mp.script_path };
648651 mp.get_time = function() { return mp.get_time_ms() / 1000 };
649652 mp.utils.getcwd = function() { return mp.get_property("working-directory") };
650653 mp.dispatch_event = dispatch_event;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t