diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-14 13:24:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 13:24:58 +0200 |
commit | fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e (patch) | |
tree | 10caa332d957421e982c7ddd0c94623d5d62314d /src/internal-server | |
parent | chore: convert various JS to TS (#2062) (diff) | |
download | ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.gz ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.tar.zst ferdium-app-fe1ba2ad6affeb6c0e97c73171d8fa3f31dde73e.zip |
chore: convert files to TS (#2066)
Diffstat (limited to 'src/internal-server')
-rw-r--r-- | src/internal-server/start.ts | 18 | ||||
-rw-r--r-- | src/internal-server/test.ts | 8 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/internal-server/start.ts b/src/internal-server/start.ts index 392f7cf41..62311b21e 100644 --- a/src/internal-server/start.ts +++ b/src/internal-server/start.ts | |||
@@ -17,27 +17,27 @@ | |||
17 | 17 | ||
18 | import fold from '@adonisjs/fold'; | 18 | import fold from '@adonisjs/fold'; |
19 | import { Ignitor } from '@adonisjs/ignitor'; | 19 | import { Ignitor } from '@adonisjs/ignitor'; |
20 | import fs from 'fs-extra'; | 20 | import { existsSync, readFile, statSync, chmodSync, writeFile } from 'fs-extra'; |
21 | import path from 'path'; | 21 | import { join } from 'path'; |
22 | import { LOCAL_HOSTNAME } from '../config'; | 22 | import { LOCAL_HOSTNAME } from '../config'; |
23 | import { isWindows } from '../environment'; | 23 | import { isWindows } from '../environment'; |
24 | 24 | ||
25 | process.env.ENV_PATH = path.join(__dirname, 'env.ini'); | 25 | process.env.ENV_PATH = join(__dirname, 'env.ini'); |
26 | 26 | ||
27 | export const server = async (userPath: string, port: number) => { | 27 | export const server = async (userPath: string, port: number) => { |
28 | const dbPath = path.join(userPath, 'server.sqlite'); | 28 | const dbPath = join(userPath, 'server.sqlite'); |
29 | const dbTemplatePath = path.join(__dirname, 'database', 'template.sqlite'); | 29 | const dbTemplatePath = join(__dirname, 'database', 'template.sqlite'); |
30 | 30 | ||
31 | if (!fs.existsSync(dbPath)) { | 31 | if (!existsSync(dbPath)) { |
32 | // Manually copy file | 32 | // Manually copy file |
33 | // We can't use copyFile here as it will cause the file to be readonly on Windows | 33 | // We can't use copyFile here as it will cause the file to be readonly on Windows |
34 | const dbTemplate = await fs.readFile(dbTemplatePath); | 34 | const dbTemplate = await readFile(dbTemplatePath); |
35 | await fs.writeFile(dbPath, dbTemplate); | 35 | await writeFile(dbPath, dbTemplate); |
36 | 36 | ||
37 | // Change permissions to ensure to file is not read-only | 37 | // Change permissions to ensure to file is not read-only |
38 | if (isWindows) { | 38 | if (isWindows) { |
39 | // eslint-disable-next-line no-bitwise | 39 | // eslint-disable-next-line no-bitwise |
40 | fs.chmodSync(dbPath, fs.statSync(dbPath).mode | 146); | 40 | chmodSync(dbPath, statSync(dbPath).mode | 146); |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
diff --git a/src/internal-server/test.ts b/src/internal-server/test.ts index 437a2813b..46d1b1e4a 100644 --- a/src/internal-server/test.ts +++ b/src/internal-server/test.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import path from 'path'; | 1 | import { join } from 'path'; |
2 | import fs from 'fs-extra'; | 2 | import { ensureDirSync } from 'fs-extra'; |
3 | import { server } from './start'; | 3 | import { server } from './start'; |
4 | 4 | ||
5 | const dummyUserFolder = path.join(__dirname, 'user_data'); | 5 | const dummyUserFolder = join(__dirname, 'user_data'); |
6 | 6 | ||
7 | fs.ensureDirSync(dummyUserFolder); | 7 | ensureDirSync(dummyUserFolder); |
8 | 8 | ||
9 | server(dummyUserFolder, 45_568); | 9 | server(dummyUserFolder, 45_568); |