diff --git a/build/build.js b/build/build.js index 91bf2c2..8222eb9 100755 --- a/build/build.js +++ b/build/build.js @@ -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 + }) ); \ No newline at end of file