forked from lnreader/lnreader-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimportPlugins.js
More file actions
24 lines (20 loc) · 807 Bytes
/
importPlugins.js
File metadata and controls
24 lines (20 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import fs from 'fs';
let content = `import { Plugin } from '@typings/plugin';\n`;
let pluginCounter = 0;
const PLUGIN_DIR = 'src/plugins';
fs.readdirSync(PLUGIN_DIR)
.filter(f => !f.includes('index'))
.forEach(langName => {
const LANG_DIR = PLUGIN_DIR + '/' + langName;
fs.readdirSync(LANG_DIR)
.filter(f => !f.includes('broken') && !f.startsWith('.'))
.forEach(pluginName => {
content += `import p_${pluginCounter} from './${langName}/${pluginName.replace(/\.ts$/, '')}';\n`;
pluginCounter += 1;
});
});
content += `\nconst PLUGINS: Plugin.PluginBase[] = [${Array(pluginCounter)
.fill()
.map((v, index) => 'p_' + index.toString())
.join(', ')}];\nexport default PLUGINS`;
fs.writeFileSync('./src/plugins/index.ts', content, { encoding: 'utf-8' });