fix: console error while building plugins without server folder

This commit is contained in:
Tom Moor
2023-06-28 21:57:34 -04:00
parent 1e4b59ac6c
commit c2af5db0f8

View File

@@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable no-undef */
const { exec } = require("child_process");
const { readdirSync } = require("fs");
const { readdirSync, existsSync } = require("fs");
const getDirectories = (source) =>
readdirSync(source, { withFileTypes: true })
@@ -45,11 +45,15 @@ async function build() {
execAsync(
"yarn babel --extensions .ts,.tsx --quiet -d ./build/shared ./shared"
),
...d.map(async (plugin) =>
execAsync(
`yarn babel --extensions .ts,.tsx --quiet -d "./build/plugins/${plugin}/server" "./plugins/${plugin}/server"`
)
),
...d.map(async (plugin) => {
const hasServer = existsSync(`./plugins/${plugin}/server`);
if (hasServer) {
await execAsync(
`yarn babel --extensions .ts,.tsx --quiet -d "./build/plugins/${plugin}/server" "./plugins/${plugin}/server"`
);
}
}),
]);
// Copy static files
@@ -75,4 +79,4 @@ async function build() {
console.log("Done!");
}
build();
void build();