Skip to content

Commit 6d3441c

Browse files
committed
Drop added PATHs on folder leave
Resolves #1078
1 parent 12bc9f1 commit 6d3441c

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

nu-hooks/nu-hooks/rusty-paths/rusty-paths.nu

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,22 @@
1313
$env.config = ($env.config | upsert hooks.env_change.PWD {
1414
append {
1515
condition: {|_, after| ($after | path join 'Cargo.lock' | path exists) }
16-
code: {
16+
code: {|_, after|
1717
$env.PATH = (
1818
$env.PATH
19-
| prepend ($env.PWD | path join 'target' 'debug')
20-
| prepend ($env.PWD | path join 'target' 'release')
19+
| prepend ($after | path join 'target' 'debug')
20+
| prepend ($after | path join 'target' 'release')
21+
| uniq
22+
)
23+
}
24+
}
25+
| append {
26+
condition: {|before, _| ($before | default '' | path join 'Cargo.lock' | path exists) }
27+
code: {|before, _|
28+
$env.PATH = (
29+
$env.PATH
30+
| where $it != ($before | path join 'target' 'debug')
31+
| where $it != ($before | path join 'target' 'release')
2132
| uniq
2233
)
2334
}

0 commit comments

Comments
 (0)