mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +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) {
|
||||
for (const item of TEMPLATE_CONTENT) {
|
||||
try {
|
||||
const folderExists = await fse.pathExists(join(process.cwd(), item));
|
||||
const pathToCopy = join(process.cwd(), item);
|
||||
|
||||
if (folderExists) {
|
||||
await fse.copy(join(process.cwd(), item), join(templatePath, item));
|
||||
const currentProjectBase = basename(process.cwd());
|
||||
console.log(
|
||||
`${chalk.green(
|
||||
'success'
|
||||
)}: copy ${currentProjectBase}/${item} => ${rootBase}/template/${item}`
|
||||
);
|
||||
if (!(await fse.pathExists(pathToCopy))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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) {
|
||||
console.error(`${chalk.red('error')}: ${error.message}`);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user