Skip to content

Commit c8e4b13

Browse files
authored
fix: do not enable export when sourcing rc file (#553)
1 parent 0c19b9b commit c8e4b13

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

docs/configuration.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pre-commit:
243243
run: npm run eslint {staged_files}
244244
```
245245

246-
Provide a tweak to access `npm` executable the same way you do it in your ~/<shell>rc
246+
Provide a tweak to access `npm` executable the same way you do it in your ~/<shell>rc.
247247

248248
```yml
249249
# lefthook-local.yml
@@ -254,16 +254,25 @@ Provide a tweak to access `npm` executable the same way you do it in your ~/<she
254254
rc: ~/.lefthookrc
255255
```
256256

257+
Or
258+
259+
```yml
260+
# lefthook-local.yml
261+
262+
# If the path contains spaces, you need to quote it.
263+
rc: '"${XDG_CONFIG_HOME:-$HOME/.config}/lefthookrc"'
264+
```
265+
266+
In the rc file, export any new environment variables or modify existing ones.
267+
257268
```bash
258269
# ~/.lefthookrc
259270
260271
# An nvm way
261-
262272
export NVM_DIR="$HOME/.nvm"
263273
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
264274
265275
# Or maybe just
266-
267276
PATH=$PATH:$HOME/.nvm/versions/node/v15.14.0/bin
268277
```
269278

internal/templates/hook.tmpl

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ if [ "$LEFTHOOK" = "0" ]; then
55
fi
66

77
{{- if .Rc}}
8-
{{/* Load rc file and export all ENV vars defined in it */}}
9-
set -a
8+
{{/* Load rc file, which may export ENV variables */}}
109
[ -f {{.Rc}} ] && . {{.Rc}}
1110
{{- end}}
1211

0 commit comments

Comments
 (0)