From 1ecc19b8b5178d3365a5a9010a3e3928cdc4412c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 27 Jan 2023 13:02:19 +0700 Subject: [PATCH] =?UTF-8?q?Cli-=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D1=8B=20--lib-dir=20=D0=B8=20--inpx=20=D0=B2=D1=8B=D0=BD?= =?UTF-8?q?=D0=B5=D1=81=D0=B5=D0=BD=D1=8B=20=D0=B2=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=B3=20(#6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++++++ server/config/base.js | 2 ++ server/config/index.js | 2 ++ server/index.js | 11 ++++++----- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e78a872..baa796a 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,14 @@ Options: При первом запуске в рабочей директории будет создан конфигурационный файл `config.json`: ```js { + // директория библиотеки (с zip-архивами), аналог параметра командной строки --lib-dir + // пустая строка: использовать значение по умолчанию - директорию файла приложения + "libDir": "", + + // путь к файлу .inpx, аналог параметра командной строки --inpx + // пустая строка: использовать значение по умолчанию - inpx-файл, что найдется в директории библиотеки + "inpx": "", + // пароль для ограничения доступа к веб-интерфейсу сервера // пустое значение - доступ без ограничений "accessPassword": "", diff --git a/server/config/base.js b/server/config/base.js index 591f0a8..9fa04a0 100644 --- a/server/config/base.js +++ b/server/config/base.js @@ -9,6 +9,8 @@ module.exports = { name: pckg.name, execDir, + libDir: '', + inpx: '', accessPassword: '', accessTimeout: 0, diff --git a/server/config/index.js b/server/config/index.js index edd1375..c8dfe9d 100644 --- a/server/config/index.js +++ b/server/config/index.js @@ -5,6 +5,8 @@ const fs = require('fs-extra'); const branchFilename = __dirname + '/application_env'; const propsToSave = [ + 'libDir', + 'inpx', 'accessPassword', 'accessTimeout', 'extendedSearch', diff --git a/server/index.js b/server/index.js index dcf5617..a93a85e 100644 --- a/server/index.js +++ b/server/index.js @@ -84,7 +84,7 @@ async function init() { } if (!config.remoteLib) { - const libDir = argv['lib-dir']; + const libDir = argv['lib-dir'] || config.libDir; if (libDir) { if (await fs.pathExists(libDir)) { config.libDir = libDir; @@ -95,11 +95,12 @@ async function init() { config.libDir = config.execDir; } - if (argv.inpx) { - if (await fs.pathExists(argv.inpx)) { - config.inpxFile = argv.inpx; + const inpxFile = argv.inpx || config.inpx; + if (inpxFile) { + if (await fs.pathExists(inpxFile)) { + config.inpxFile = inpxFile; } else { - throw new Error(`File "${argv.inpx}" not found`); + throw new Error(`File "${inpxFile}" not found`); } } else { const inpxFiles = [];