Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,43 @@ const { configFile, created } = await updateConfig({
console.log(`Config file ${created ? "created" : "updated"} in ${configFile}`);
```

### Updating RC config files

Update or create RC configuration files using [rc9](https://github.com/unjs/rc9).

Import utils from `c12/update`:

```js
import { updateConfigRC } from "c12/update";
```

**Update RC config:**

```js
const configFile = await updateConfigRC({
name: ".myapprc",
dir: process.cwd(), // optional, defaults to cwd
onUpdate: (config) => {
config.apiUrl = "https://api.example.com";
config.enabled = true;
},
});

console.log(`RC config updated in ${configFile}`);
```

RC files use a simple key-value format with automatic flattening/unflattening:

```ini
# .myapprc
apiUrl=https://api.example.com
enabled=true
database.host=localhost
database.port=5432
```

Learn more about RC file format in [rc9 documentation](https://github.com/unjs/rc9).

## Configuration functions

You can use a function to define your configuration dynamically based on context.
Expand Down
Loading