Skip to content

Commit b9e5eac

Browse files
committed
Fix code
1 parent 345d2e4 commit b9e5eac

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

vignettes/rprojroot.Rmd

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,20 @@ root <- rprojroot::is_r_package
6060
The `root` object contains a function that helps locating files below the root
6161
of your package, regardless of your current working directory.
6262
If you are sure that your working directory is somewhere below your project's root,
63-
use the `root$find_file()` function:
63+
use the `root$find_file()` function.
64+
In this example here, we're starting in the `vignettes` subdirectory and find the original `DESCRIPTION` file:
6465

6566
```{r}
67+
basename(getwd())
6668
readLines(root$find_file("DESCRIPTION"), 3)
6769
```
6870

69-
This works identically when starting from a subdirectory:
70-
71-
```{r}
72-
withr::with_dir(
73-
"R",
74-
readLines(root$find_file(path, "DESCRIPTION"), 3)
75-
)
76-
```
77-
7871
There is one exception: if the first component passed to `find_file()` is already an absolute path.
7972
This allows safely applying this function to paths that may be absolute or relative:
8073

8174
```{r}
82-
path <- root_file("DESCRIPTION")
83-
withr::with_dir(
84-
"R",
85-
readLines(root$find_file(path, "DESCRIPTION"), 3)
86-
)
75+
path <- root$find_file()
76+
readLines(root$find_file(path, "DESCRIPTION"), 3)
8777
```
8878

8979
You can also

0 commit comments

Comments
 (0)