fix: copy file if it does not exist
This commit is contained in:
parent
f19aac1763
commit
cd2dabc4d9
1 changed files with 13 additions and 2 deletions
|
|
@ -158,12 +158,23 @@ async function update_assets_obj(app, assets, assets_rtl) {
|
|||
const app_path = path.join(apps_path, app, app);
|
||||
const dist_path = path.join(app_path, "public", "dist");
|
||||
const files = await glob("**/*.bundle.*.{js,css}", { cwd: dist_path });
|
||||
const prefix = path.join("/", "assets", app, "dist");
|
||||
const assets_dist = path.join("assets", app, "dist");
|
||||
const prefix = path.join("/", assets_dist);
|
||||
|
||||
// eg: "js/marketplace.bundle.6SCSPSGQ.js"
|
||||
for (const file of files) {
|
||||
const source_path = path.join(dist_path, file);
|
||||
const dest_path = path.join(sites_path, assets_dist, file);
|
||||
|
||||
// Copy asset file from app/public to sites/assets
|
||||
if (!fs.existsSync(dest_path)) {
|
||||
const dest_dir = path.dirname(dest_path);
|
||||
fs.mkdirSync(dest_dir, { recursive: true });
|
||||
fs.copyFileSync(source_path, dest_path);
|
||||
}
|
||||
|
||||
// eg: [ "marketplace", "bundle", "6SCSPSGQ", "js" ]
|
||||
const parts = path.parse(file).base.split(".");
|
||||
const parts = path.basename(file).split(".");
|
||||
|
||||
// eg: "marketplace.bundle.js"
|
||||
const key = [...parts.slice(0, -2), parts.at(-1)].join(".");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue