replace __dirname in favor of process.cwd in diff command web flag #2856
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🍗 Description
What does this PR do? Anything folks should know?
A bit of context: to facilitate the consumption of
@useoptic/optic
, we package it using pkg to make it an executable.If I run the diff command using native TypeScript compilers such as ts-node, I have no issue because the final HTML file resolves to a local file in my filesystem, for example,
file:///Users/xxxxxxx/work/tools/tool-api-standards/node_modules/@useoptic/optic/web/build/index.html#W0cZF0U
But because we package using pkg, it prefixes the local file path with snapshot, so it becomes:
file:///snapshot/tool-api-standards/node_modules/@useoptic/optic/web/build/index.html#W0cZF0U
I think it is caused by
maybeChangelogUrl
found in the following line in combination with our use of pkg to make executables: maybeChangelogUrlpkg recommends to use
process.cwd()
instead of__dirname
One can assert the following is true:
(process.execPath) === __dirname === true
📚 References
Links to relevant docs (Notion, Twist, GH issues, etc.), if applicable.
https://www.npmjs.com/package/pkg#snapshot-filesystem
https://www.npmjs.com/package/ts-node
👹 QA
How can other humans verify that this PR is correct?
When running
diff
with the--web
flag, it should open a browser window with the results.