Skip to content

Commit

Permalink
doc: Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 2, 2023
1 parent 47a2942 commit 3f25888
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,32 @@ Additionally, you have the option to put a property named after the tool in your

This has the advantage that you can put the configuration of all tools (at least the ones that use `auto-config-loader`) in one file.

## loader

Modify default `.js`,`.ts`,`.cjs`,`.mjs` loader parameters.

```js
import load, { jsLoader } from 'auto-config-loader';
function loadJS(filepath, content) {
return jsLoader(filepath, content, {
// change option...
});
}
const data = load('namespace', {
loaders: {
'.js': loadJS,
'.ts': loadJS,
'.cjs': loadJS,
'.mjs': loadJS,
},
defaults: {
testItem2: 'some value'
}
});
```

## Yaml loader

This is an example, the default `yaml`/`yml` does not require a loader.
Expand All @@ -165,7 +191,7 @@ function loadYaml(filepath, content) {
return yaml.parse(content);
}
await load('namespace', {
const data = load('namespace', {
searchPlaces: [
'.namespacerc.yaml',
'.namespacerc.yml',
Expand Down

0 comments on commit 3f25888

Please sign in to comment.