You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/README.md
+68-11Lines changed: 68 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ Auto Config Loader
9
9
10
10
Find and load configuration from a `package.json` property, `rc` file, or `CommonJS` module. It has smart default based on traditional expectations in the JavaScript ecosystem. But it's also flexible enough to search anywhere you want and load whatever you want.
11
11
12
+
[V1 To V2 Migration](#v1-to-v2-migration)
13
+
12
14
## Features
13
15
14
16
- Support [JSON](https://www.json.org), [JSONC](https://github.com/microsoft/node-jsonc-parser), [JSON5](https://json5.org/), [YAML](https://yaml.org/), [TOML](https://toml.io), [INI](https://en.wikipedia.org/wiki/INI_file), [CJS](http://www.commonjs.org), [Typescript](https://www.typescriptlang.org/), and ESM config load.
@@ -43,7 +45,7 @@ import { autoConf } from 'auto-config-loader';
43
45
// process.cwd() + 'namespace.config.cjs'
44
46
// process.cwd() + 'namespace.config.js'
45
47
// ........
46
-
constdata=autoConf('namespace', {
48
+
constdata=awaitautoConf('namespace', {
47
49
default: {
48
50
testItem2:'some value'
49
51
}
@@ -68,22 +70,22 @@ interface Config {
68
70
name:string;
69
71
}
70
72
71
-
const result =loadConf<Config>('./app/app.config.js');
73
+
const result =awaitloadConf<Config>('./app/app.config.js');
Discover configurations in the specified directory order. When configuring a tool, you can use multiple file formats and put these in multiple places. Usually, a tool would mention this in its own README file, but by default, these are the following places, where `${moduleName}` represents the name of the tool:
@@ -187,7 +191,7 @@ function loadJS(filepath, content) {
187
191
});
188
192
}
189
193
190
-
const data = load('namespace', {
194
+
const data = await load('namespace', {
191
195
loaders: {
192
196
'.js': loadJS,
193
197
'.ts': loadJS,
@@ -276,7 +280,7 @@ function loadYaml(filepath, content) {
276
280
returnyaml.parse(content);
277
281
}
278
282
279
-
constdata=load('namespace', {
283
+
constdata=awaitload('namespace', {
280
284
searchPlaces: [
281
285
'.namespacerc.yaml',
282
286
'.namespacerc.yml',
@@ -298,9 +302,9 @@ const data = load('namespace', {
0 commit comments