diff --git a/core/src/modules/editor.js b/core/src/modules/editor.js index df7837ab..1e7860cb 100644 --- a/core/src/modules/editor.js +++ b/core/src/modules/editor.js @@ -46,6 +46,9 @@ export default class Editor extends Module { })); const userscssPath = path.resolve(this.bd.config.getPath('data'), 'user.scss'); + + await FileUtils.ensureFile(userscssPath); + const userscss = await FileUtils.readFile(userscssPath); constructFiles.push({ caption: 'userstyle', diff --git a/core/src/modules/utils.js b/core/src/modules/utils.js index 66586e7f..bb071023 100644 --- a/core/src/modules/utils.js +++ b/core/src/modules/utils.js @@ -85,6 +85,20 @@ export class FileUtils { }); } + static async ensureFile(path) { + try { + await this.fileExists(path); + return true; + } catch (err) { + try { + await this.writeFile(path, ''); + return true; + } catch (err) { + throw err; + } + } + } + static async readJsonFromFile(path) { let readFile; try {