Cli-параметры --lib-dir и --inpx вынесены в конфиг (#6)
This commit is contained in:
@@ -80,6 +80,14 @@ Options:
|
||||
При первом запуске в рабочей директории будет создан конфигурационный файл `config.json`:
|
||||
```js
|
||||
{
|
||||
// директория библиотеки (с zip-архивами), аналог параметра командной строки --lib-dir
|
||||
// пустая строка: использовать значение по умолчанию - директорию файла приложения
|
||||
"libDir": "",
|
||||
|
||||
// путь к файлу .inpx, аналог параметра командной строки --inpx
|
||||
// пустая строка: использовать значение по умолчанию - inpx-файл, что найдется в директории библиотеки
|
||||
"inpx": "",
|
||||
|
||||
// пароль для ограничения доступа к веб-интерфейсу сервера
|
||||
// пустое значение - доступ без ограничений
|
||||
"accessPassword": "",
|
||||
|
||||
@@ -9,6 +9,8 @@ module.exports = {
|
||||
name: pckg.name,
|
||||
|
||||
execDir,
|
||||
libDir: '',
|
||||
inpx: '',
|
||||
|
||||
accessPassword: '',
|
||||
accessTimeout: 0,
|
||||
|
||||
@@ -5,6 +5,8 @@ const fs = require('fs-extra');
|
||||
const branchFilename = __dirname + '/application_env';
|
||||
|
||||
const propsToSave = [
|
||||
'libDir',
|
||||
'inpx',
|
||||
'accessPassword',
|
||||
'accessTimeout',
|
||||
'extendedSearch',
|
||||
|
||||
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user