mirror of
https://github.com/astefanutti/decktape.git
synced 2025-01-07 14:58:31 +03:00
Load plugins relative to decktape module directory
This commit is contained in:
parent
3c9be0b7f3
commit
c0d8df443a
13
decktape.js
Normal file → Executable file
13
decktape.js
Normal file → Executable file
@ -5,11 +5,12 @@ const BufferReader = require("./libs/buffer")
|
||||
hummus = require('hummus'),
|
||||
os = require('os'),
|
||||
parser = require('./libs/nomnom'),
|
||||
path = require('path'),
|
||||
puppeteer = require('puppeteer');
|
||||
|
||||
const { delay, value } = require('./libs/promise');
|
||||
|
||||
const plugins = loadAvailablePlugins('./plugins/');
|
||||
const plugins = loadAvailablePlugins(path.join(path.dirname(__filename), 'plugins'));
|
||||
|
||||
parser.script('decktape')
|
||||
.options({
|
||||
@ -296,11 +297,11 @@ async function exportSlide(plugin) {
|
||||
|
||||
})();
|
||||
|
||||
function loadAvailablePlugins(pluginPath) {
|
||||
return fs.readdirSync(pluginPath).reduce(function (plugins, plugin) {
|
||||
var matches = plugin.match(/^(.*)\.js$/);
|
||||
if (matches && fs.statSync(pluginPath + plugin).isFile())
|
||||
plugins[matches[1]] = require(pluginPath + matches[1]);
|
||||
function loadAvailablePlugins(pluginsPath) {
|
||||
return fs.readdirSync(pluginsPath).reduce((plugins, pluginPath) => {
|
||||
const [, plugin] = pluginPath.match(/^(.*)\.js$/);
|
||||
if (plugin && fs.statSync(path.join(pluginsPath, pluginPath)).isFile())
|
||||
plugins[plugin] = require('./plugins/' + plugin);
|
||||
return plugins;
|
||||
}, {});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user