MCPcopy
hub / github.com/walterhiggins/ScriptCraft / _autoload

Function _autoload

src/main/js/lib/plugin.js:33–68  ·  view source on GitHub ↗
(context, pluginDir, options)

Source from the content-addressed store, hash-verified

31}
32
33function _autoload(context, pluginDir, options) {
34 /*
35 Reload all of the .js files in the given directory
36 */
37 var sourceFiles = [],
38 property,
39 module,
40 pluginPath;
41 sourceFiles = find(pluginDir);
42
43 var len = sourceFiles.length;
44 if (config && config.verbose) {
45 console.info(len + ' scriptcraft plugins found in ' + pluginDir);
46 }
47
48 for (var i = 0; i < len; i++) {
49 pluginPath = sourceFiles[i];
50 if (!pluginPath.match(/\.js$/)) {
51 continue;
52 }
53 module = {};
54
55 try {
56 module = require(pluginPath, options);
57 for (property in module) {
58 /*
59 all exports in plugins become members of context object
60 */
61 context[property] = module[property];
62 }
63 } catch (e) {
64 var msg = 'Plugin ' + pluginPath + ' ' + e;
65 console.error(msg);
66 }
67 }
68}
69exports.plugin = _plugin;
70exports.autoload = _autoload;

Callers

nothing calls this directly

Calls 1

findFunction · 0.85

Tested by

no test coverage detected