generated from Seekra/repository-template
Feat(legal): legal notice #8
+22
-6
@@ -20,20 +20,33 @@ import { processPlugin } from './utils/plugin.js';
|
|||||||
import { readdir } from 'node:fs/promises';
|
import { readdir } from 'node:fs/promises';
|
||||||
import { join } from 'node:path';
|
import { join } from 'node:path';
|
||||||
import { pathToFileURL } from 'node:url';
|
import { pathToFileURL } from 'node:url';
|
||||||
|
import { parseArgs } from 'node:util';
|
||||||
|
|
||||||
const dir = './build/plugins';
|
const dir = './build/plugins';
|
||||||
|
|
||||||
const files = await readdir(dir);
|
const files = await readdir(dir);
|
||||||
|
|
||||||
const tryToProcessPlugin = async function tryToProcessPlugin (plugin) {
|
const tryToProcessPlugin = async function tryToProcessPlugin (plugin, options) {
|
||||||
if (typeof plugin.default === 'function') {
|
if (typeof plugin.default === 'function') {
|
||||||
await processPlugin(plugin.default, {
|
await processPlugin(plugin.default, options);
|
||||||
srcBase: './src',
|
|
||||||
distBase: './dist'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { values: args } = parseArgs({
|
||||||
|
options: {
|
||||||
|
distBase: {
|
||||||
|
type: 'string',
|
||||||
|
short: 'd',
|
||||||
|
default: './dist/'
|
||||||
|
},
|
||||||
|
srcBase: {
|
||||||
|
type: 'string',
|
||||||
|
short: 's',
|
||||||
|
default: './src/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
(await Promise.all(
|
(await Promise.all(
|
||||||
files
|
files
|
||||||
.filter((file) => file.endsWith('.js'))
|
.filter((file) => file.endsWith('.js'))
|
||||||
@@ -41,5 +54,8 @@ const tryToProcessPlugin = async function tryToProcessPlugin (plugin) {
|
|||||||
import(pathToFileURL(join(dir, file)).href)
|
import(pathToFileURL(join(dir, file)).href)
|
||||||
)
|
)
|
||||||
)).forEach(
|
)).forEach(
|
||||||
async (plugin) => tryToProcessPlugin(plugin)
|
async (plugin) => tryToProcessPlugin(plugin, {
|
||||||
|
srcBase: args.srcBase,
|
||||||
|
distBase: args.distBase
|
||||||
|
})
|
||||||
);
|
);
|
||||||
Reference in New Issue
Block a user