throw error when public folder could not be created

This commit is contained in:
Pierre Noël 2022-02-22 11:37:21 +01:00
parent 6e17361e32
commit e28cdc8a4a
2 changed files with 15 additions and 3 deletions

View File

@ -3,7 +3,7 @@
const { getConfigUrls } = require('@strapi/utils');
const fse = require('fs-extra');
module.exports = function({ strapi }) {
module.exports = async function({ strapi }) {
strapi.config.port = strapi.config.get('server.port') || strapi.config.port;
strapi.config.host = strapi.config.get('server.host') || strapi.config.host;
@ -25,5 +25,11 @@ module.exports = function({ strapi }) {
}
// ensure public repository exists
fse.ensureDir(strapi.dirs.public);
try {
await fse.ensureDir(strapi.dirs.public);
} catch (e) {
throw new Error(
`The public folder (${strapi.dirs.public}) doesn't exist. Please make sure it exists.`
);
}
};

View File

@ -22,7 +22,13 @@ module.exports = {
// Ensure uploads folder exists
const uploadPath = path.resolve(strapi.dirs.public, UPLOADS_FOLDER_NAME);
fse.ensureDirSync(uploadPath);
try {
fse.ensureDirSync(uploadPath);
} catch (e) {
throw new Error(
`The upload folder (${uploadPath}) doesn't exist. Please make sure it exists.`
);
}
return {
upload(file) {