-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use lazily evaluated process.cwd as a default config value (#150)
* fix: use lazily evaluated process.cwd as a default config value * chore: add changeset
- Loading branch information
1 parent
078096e
commit 04fe22d
Showing
2 changed files
with
54 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
"skott": patch | ||
--- | ||
|
||
This patch fixes the eager evaluation of `cwd` default value from the config preventing [process.chdir](https://nodejs.org/api/process.html#processchdirdirectory) | ||
to work as expected when used before invoking skott's API. | ||
|
||
```js | ||
process.chdir('/tmp/somewhere'); | ||
|
||
// skott is now being executed at the root of "/tmp/somewhere" | ||
|
||
const instance = await skott(); | ||
``` | ||
|
||
Note: regarding the generated graph relationships, this is pretty much equivalent as doing `skott({ cwd: "/tmp/somewhere" })`, even though | ||
node paths will be relative and won't have the same values as the later still executes skott from the script location | ||
and not from `/tmp/somewhere`. In other words, using `cwd` parameter will have node paths being relative to skott's script location, while using | ||
`process.chdir` will make skott execute the script from the provided directory. | ||
|
||
You can find a real example of the difference between node paths using `process.chdir` and `cwd`: https://github.com/antoine-coulon/skott/issues/149#issuecomment-1989451725 | ||
by @mattkindy. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters