Cli-параметры --lib-dir и --inpx вынесены в конфиг (#6)

This commit is contained in:
Book Pauk
2023-01-27 13:02:19 +07:00
parent 7ef1520756
commit 1ecc19b8b5
4 changed files with 18 additions and 5 deletions

View File

@@ -80,6 +80,14 @@ Options:
При первом запуске в рабочей директории будет создан конфигурационный файл `config.json`:
```js
{
// директория библиотеки (с zip-архивами), аналог параметра командной строки --lib-dir
// пустая строка: использовать значение по умолчанию - директорию файла приложения
"libDir": "",
// путь к файлу .inpx, аналог параметра командной строки --inpx
// пустая строка: использовать значение по умолчанию - inpx-файл, что найдется в директории библиотеки
"inpx": "",
// пароль для ограничения доступа к веб-интерфейсу сервера
// пустое значение - доступ без ограничений
"accessPassword": "",

View File

@@ -9,6 +9,8 @@ module.exports = {
name: pckg.name,
execDir,
libDir: '',
inpx: '',
accessPassword: '',
accessTimeout: 0,

View File

@@ -5,6 +5,8 @@ const fs = require('fs-extra');
const branchFilename = __dirname + '/application_env';
const propsToSave = [
'libDir',
'inpx',
'accessPassword',
'accessTimeout',
'extendedSearch',

View File

@@ -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 = [];