aboutsummaryrefslogtreecommitdiffstats
path: root/src/internal-server/start.js
diff options
context:
space:
mode:
authorLibravatar mhatvan <markus_hatvan@aon.at>2021-08-05 08:58:28 +0200
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-08-05 08:05:49 +0000
commit305c2c5ecb49a1349be2efb1ef557d61da9a64dc (patch)
tree19a05ed4ddfc1e5b5bb7fc3ecc071ad562da820f /src/internal-server/start.js
parentrefactor: minor refactoring: solve name-clash of env vars vs vars in the program (diff)
downloadferdium-app-305c2c5ecb49a1349be2efb1ef557d61da9a64dc.tar.gz
ferdium-app-305c2c5ecb49a1349be2efb1ef557d61da9a64dc.tar.zst
ferdium-app-305c2c5ecb49a1349be2efb1ef557d61da9a64dc.zip
refactor: general code improvements
- replace deprecated fs.exists with fs.existsSync - replace console.log with debug - replace hardcoded FERDI_VERSION in start.js with dynamic one from package.json - correct JSDoc annotations in Handler.js - simplify macOSPermissions.js - updates to various eslint rules - add FileReader to known globals
Diffstat (limited to 'src/internal-server/start.js')
-rw-r--r--src/internal-server/start.js17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/internal-server/start.js b/src/internal-server/start.js
index adcac0bec..683f24651 100644
--- a/src/internal-server/start.js
+++ b/src/internal-server/start.js
@@ -14,22 +14,22 @@
14| Also you can preload files by calling `preLoad('path/to/file')` method. 14| Also you can preload files by calling `preLoad('path/to/file')` method.
15| Make sure to pass a relative path from the project root. 15| Make sure to pass a relative path from the project root.
16*/ 16*/
17process.env.FERDI_VERSION = '5.4.0-beta.5';
18 17
19const path = require('path'); 18const fold = require('@adonisjs/fold');
19const { Ignitor } = require('@adonisjs/ignitor');
20const fs = require('fs-extra'); 20const fs = require('fs-extra');
21const os = require('os'); 21const os = require('os');
22const path = require('path');
23const packageJSON = require('../../package.json');
22 24
25process.env.FERDI_VERSION = packageJSON.version;
23process.env.ENV_PATH = path.join(__dirname, 'env.ini'); 26process.env.ENV_PATH = path.join(__dirname, 'env.ini');
24 27
25const { Ignitor } = require('@adonisjs/ignitor');
26const fold = require('@adonisjs/fold');
27
28module.exports = async (userPath, port) => { 28module.exports = async (userPath, port) => {
29 const dbPath = path.join(userPath, 'server.sqlite'); 29 const dbPath = path.join(userPath, 'server.sqlite');
30 const dbTemplatePath = path.join(__dirname, 'database', 'template.sqlite'); 30 const dbTemplatePath = path.join(__dirname, 'database', 'template.sqlite');
31 31
32 if (!await fs.exists(dbPath)) { 32 if (!fs.existsSync(dbPath)) {
33 // Manually copy file 33 // Manually copy file
34 // We can't use copyFile here as it will cause the file to be readonly on Windows 34 // We can't use copyFile here as it will cause the file to be readonly on Windows
35 const dbTemplate = await fs.readFile(dbTemplatePath); 35 const dbTemplate = await fs.readFile(dbTemplatePath);
@@ -46,8 +46,5 @@ module.exports = async (userPath, port) => {
46 process.env.USER_PATH = userPath; 46 process.env.USER_PATH = userPath;
47 process.env.PORT = port; 47 process.env.PORT = port;
48 48
49 new Ignitor(fold) 49 new Ignitor(fold).appRoot(__dirname).fireHttpServer().catch(console.error); // eslint-disable-line no-console
50 .appRoot(__dirname)
51 .fireHttpServer()
52 .catch(console.error); // eslint-disable-line no-console
53}; 50};