|
|
@ -1,5 +1,5 @@ |
|
|
import path from "path"; |
|
|
import path from "path"; |
|
|
import {mkdir, copyFile} from "fs/promises"; |
|
|
import fs, {mkdir, copyFile} from "fs/promises"; |
|
|
import {capitalize, createFiles, getBlockName, getConfigs, readJSONFile} from "../../helpers.js"; |
|
|
import {capitalize, createFiles, getBlockName, getConfigs, readJSONFile} from "../../helpers.js"; |
|
|
import {fileURLToPath} from 'url'; |
|
|
import {fileURLToPath} from 'url'; |
|
|
import {copy} from "fs-extra"; |
|
|
import {copy} from "fs-extra"; |
|
|
@ -68,10 +68,17 @@ export async function buildWordPress(blockName, args = {}) { |
|
|
path.join(distPath, 'templates', 'scripts', `${data.blockFilename}.min.js`), |
|
|
path.join(distPath, 'templates', 'scripts', `${data.blockFilename}.min.js`), |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
const imagesPath = path.join(projectPath, 'src', 'images'); |
|
|
|
|
|
await fs.access(imagesPath); |
|
|
|
|
|
|
|
|
await copy( |
|
|
await copy( |
|
|
path.join(projectPath, 'src', 'images'), |
|
|
path.join(imagesPath), |
|
|
path.join(distPath, 'templates', 'images'), |
|
|
path.join(distPath, 'templates', 'images'), |
|
|
); |
|
|
); |
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
// Folder doesn't exist.
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const phpDataObject = await execPHPFile(path.join(phpGeneratorPath, 'build.php'), 'jsonToPhp', { |
|
|
const phpDataObject = await execPHPFile(path.join(phpGeneratorPath, 'build.php'), 'jsonToPhp', { |
|
|
json: await readJSONFile(path.join(projectPath, 'data', 'default.json'), "utf8"), |
|
|
json: await readJSONFile(path.join(projectPath, 'data', 'default.json'), "utf8"), |
|
|
|