mirror of
https://github.com/strapi/strapi.git
synced 2025-11-18 19:22:05 +00:00
exit loop if path doesn't exist
This commit is contained in:
parent
eec4aa2e56
commit
c318c3d809
@ -16,17 +16,19 @@ const TEMPLATE_CONTENT = ['api', 'components', 'config/functions/bootstrap.js',
|
|||||||
async function copyContent(templatePath, rootBase) {
|
async function copyContent(templatePath, rootBase) {
|
||||||
for (const item of TEMPLATE_CONTENT) {
|
for (const item of TEMPLATE_CONTENT) {
|
||||||
try {
|
try {
|
||||||
const folderExists = await fse.pathExists(join(process.cwd(), item));
|
const pathToCopy = join(process.cwd(), item);
|
||||||
|
|
||||||
if (folderExists) {
|
if (!(await fse.pathExists(pathToCopy))) {
|
||||||
await fse.copy(join(process.cwd(), item), join(templatePath, item));
|
continue;
|
||||||
const currentProjectBase = basename(process.cwd());
|
|
||||||
console.log(
|
|
||||||
`${chalk.green(
|
|
||||||
'success'
|
|
||||||
)}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await fse.copy(pathToCopy, join(templatePath, item));
|
||||||
|
const currentProjectBase = basename(process.cwd());
|
||||||
|
console.log(
|
||||||
|
`${chalk.green(
|
||||||
|
'success'
|
||||||
|
)}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`${chalk.red('error')}: ${error.message}`);
|
console.error(`${chalk.red('error')}: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user