diff options
author | mhatvan <markus_hatvan@aon.at> | 2021-08-05 08:58:28 +0200 |
---|---|---|
committer | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-08-05 08:05:49 +0000 |
commit | 305c2c5ecb49a1349be2efb1ef557d61da9a64dc (patch) | |
tree | 19a05ed4ddfc1e5b5bb7fc3ecc071ad562da820f /src/internal-server/start.js | |
parent | refactor: minor refactoring: solve name-clash of env vars vs vars in the program (diff) | |
download | ferdium-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.js | 17 |
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 | */ |
17 | process.env.FERDI_VERSION = '5.4.0-beta.5'; | ||
18 | 17 | ||
19 | const path = require('path'); | 18 | const fold = require('@adonisjs/fold'); |
19 | const { Ignitor } = require('@adonisjs/ignitor'); | ||
20 | const fs = require('fs-extra'); | 20 | const fs = require('fs-extra'); |
21 | const os = require('os'); | 21 | const os = require('os'); |
22 | const path = require('path'); | ||
23 | const packageJSON = require('../../package.json'); | ||
22 | 24 | ||
25 | process.env.FERDI_VERSION = packageJSON.version; | ||
23 | process.env.ENV_PATH = path.join(__dirname, 'env.ini'); | 26 | process.env.ENV_PATH = path.join(__dirname, 'env.ini'); |
24 | 27 | ||
25 | const { Ignitor } = require('@adonisjs/ignitor'); | ||
26 | const fold = require('@adonisjs/fold'); | ||
27 | |||
28 | module.exports = async (userPath, port) => { | 28 | module.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 | }; |