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