diff --git a/electron/src/electron.ts b/electron/src/electron.ts index ffe380f6c..f6592ab98 100644 --- a/electron/src/electron.ts +++ b/electron/src/electron.ts @@ -6,6 +6,8 @@ import appIconService = require("./services/app_icon"); import windowService = require("./services/window"); import tray = require("./services/tray"); +import startTrilium = require("../../server/src/www.js"); + // Adds debug features like hotkeys for triggering dev tools and reload require("electron-debug")(); @@ -60,4 +62,4 @@ electron.app.on("will-quit", () => { // this is to disable electron warning spam in the dev console (local development only) process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true"; -require("../../server/src/www.js"); // path is relative to dist/electron/src as defined in package.lock main +startTrilium(); \ No newline at end of file diff --git a/server/package.json b/server/package.json index 72a52df25..ed98f39f1 100644 --- a/server/package.json +++ b/server/package.json @@ -2,11 +2,11 @@ "name": "server", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "src/index.ts", "scripts": { - "start-server": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts", - "start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts", - "qstart-server": "npm run qswitch-server && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon src/www.ts" + "start-server": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon .", + "start-server-no-dir": "cross-env TRILIUM_SAFE_MODE=1 TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon .", + "qstart-server": "npm run qswitch-server && TRILIUM_SAFE_MODE=1 TRILIUM_DATA_DIR=./data TRILIUM_ENV=dev TRILIUM_SYNC_SERVER_HOST=http://tsyncserver:4000 nodemon ." }, "dependencies": { "@braintree/sanitize-url": "6.0.4", diff --git a/server/src/index.ts b/server/src/index.ts new file mode 100644 index 000000000..8b78f3e0f --- /dev/null +++ b/server/src/index.ts @@ -0,0 +1,3 @@ +import startTrilium = require("./www"); + +startTrilium(); \ No newline at end of file diff --git a/server/src/www.ts b/server/src/www.ts index 3f9aa752e..8ab3c6321 100644 --- a/server/src/www.ts +++ b/server/src/www.ts @@ -32,14 +32,12 @@ import port = require('./services/port'); import host = require('./services/host'); import semver = require('semver'); -if (!semver.satisfies(process.version, ">=10.5.0")) { - console.error("Trilium only supports node.js 10.5 and later"); - process.exit(1); -} - -startTrilium(); - function startTrilium() { + if (!semver.satisfies(process.version, ">=10.5.0")) { + console.error("Trilium only supports node.js 10.5 and later"); + process.exit(1); + } + /** * The intended behavior is to detect when a second instance is running, in that case open the old instance * instead of the new one. This is complicated by the fact that it is possible to run multiple instances of Trilium @@ -156,3 +154,5 @@ function startHttpServer() { return httpServer; } + +export = startTrilium; \ No newline at end of file