|
1 | 1 | function refresh!(path, original_options, options = original_options)
|
2 |
| - # Current directory should always start out as the directory of the |
3 |
| - # notebook file, which is not necessarily right initially if the parent |
4 |
| - # process was started from a different directory to the notebook. |
5 |
| - cd(dirname(path)) |
6 | 2 | task_local_storage()[:SOURCE_PATH] = path
|
| 3 | + |
| 4 | + # We check the `execute-dir` key in the options, |
| 5 | + if haskey(options, "project") && haskey(options["project"], "execute-dir") |
| 6 | + ed = options["project"]["execute-dir"] |
| 7 | + if ed == "directory" |
| 8 | + println("cd(dirname(path))") |
| 9 | + cd(dirname(path)) |
| 10 | + elseif ed == "project" |
| 11 | + # TODO: this doesn't seem right. How does one get the root path of the project here? |
| 12 | + # Maybe piggyback on `options` with some ridiculous identifier? |
| 13 | + println("cd(NotebookState.PROJECT[])") |
| 14 | + if isfile(NotebookState.PROJECT[]) |
| 15 | + cd(dirname(NotebookState.PROJECT[])) |
| 16 | + elseif isdir(NotebookState.PROJECT[]) |
| 17 | + cd(NotebookState.PROJECT[]) |
| 18 | + else |
| 19 | + @warn "Project path not found: $(NotebookState.PROJECT[])" |
| 20 | + end |
| 21 | + else |
| 22 | + println("cd(abspath(options[\"execute-dir\"])) => cd($(abspath(ed)))") |
| 23 | + cd(abspath(ed)) |
| 24 | + end |
| 25 | + else |
| 26 | + # Current directory should always start out as the directory of the |
| 27 | + # notebook file, which is not necessarily right initially if the parent |
| 28 | + # process was started from a different directory to the notebook. |
| 29 | + cd(dirname(path)) |
| 30 | + end |
7 | 31 |
|
8 | 32 | # Reset back to the original project environment if it happens to
|
9 | 33 | # have changed during cell evaluation.
|
|
0 commit comments