Skip to content

Commit

Permalink
feat: custom rc path (antfu-collective#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
MuXiu1997 authored Nov 14, 2021
1 parent 723fe02 commit 35960e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ nr -C playground dev

### Config

```bash
# ~/.bashrc

# custom configuration file path
export NI_CONFIG_FILE="$HOME/.config/ni/nirc"
```

```ini
; ~/.nirc

Expand Down
6 changes: 5 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import path from 'path'
import ini from 'ini'
import { Agent } from './agents'

const customRcPath = process.env.NI_CONFIG_FILE

const home = process.platform === 'win32'
? process.env.USERPROFILE
: process.env.HOME

const rcPath = path.join(home || '~/', '.nirc')
const defaultRcPath = path.join(home || '~/', '.nirc')

const rcPath = customRcPath || defaultRcPath

interface Config {
defaultAgent: Agent | 'prompt'
Expand Down

0 comments on commit 35960e4

Please sign in to comment.