-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from core-ds/fix/presets-from-config
fix(config): allow to set presets path from config file
- Loading branch information
Showing
4 changed files
with
36 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'arui-scripts': patch | ||
--- | ||
|
||
Исправлена ошибка, не позволявшая задать пресеты через конфиг-файл |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/arui-scripts/src/configs/app-configs/read-config-file.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import path from 'path'; | ||
|
||
import { tryResolve } from '../util/resolve'; | ||
|
||
export function readConfigFile(cwd: string) { | ||
const appConfigPath = tryResolve(path.join(cwd, '/arui-scripts.config')); | ||
|
||
if (appConfigPath) { | ||
// Мы не можем использовать импорты, нам нужен именно require, потому что мы не знаем заранее не только путь до файла, | ||
// но и то, на каком языке он написан | ||
// eslint-disable-next-line import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires | ||
let appSettings = require(appConfigPath); | ||
|
||
// ts-node импортирует esModules, из них надо вытягивать default именно так | ||
// eslint-disable-next-line no-underscore-dangle | ||
if (appSettings.__esModule) { | ||
appSettings = appSettings.default; | ||
} | ||
|
||
return appSettings; | ||
} | ||
|
||
return null; | ||
} |
20 changes: 4 additions & 16 deletions
20
packages/arui-scripts/src/configs/app-configs/update-with-config-file.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters