fix(cli): use resolve instead of join for report path in open command#688
Open
todti wants to merge 2 commits into
Open
fix(cli): use resolve instead of join for report path in open command#688todti wants to merge 2 commits into
todti wants to merge 2 commits into
Conversation
path.join does not treat an absolute second argument as absolute — it concatenates both, stripping the leading slash. resolveConfig always returns an absolute output path, so when allure open is invoked without a path argument the fallback config.output was doubled into the cwd, producing a path like: /sandbox/Users/.../sandbox/allure-report Switching to path.resolve fixes this: if the fallback is already absolute it is returned as-is; if it is relative it is resolved against cwd, which is the correct behaviour in both cases.
…path path.join(cwd, absolutePath) strips the leading slash of the second argument and concatenates, doubling the path. Use isAbsolute() to short-circuit: if the resolved config.output is already absolute (which readConfig always produces), return it directly; otherwise fall back to join(cwd, relativePath) for relative inputs.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
resolveConfigalways resolvesoutputto an absolute path viapath.resolveresolveReportPathusedpath.join(cwd, fallback)wherefallbackcould be that absolute pathpath.joindoes not treat an absolute second argument as absolute — it strips the leading/and concatenates, producing a doubled path like/sandbox/Users/.../sandbox/allure-reportpath.resolve(cwd, path)which correctly passes through absolute paths and resolves relative ones againstcwdReproduces when running
allure openwithout a path argument (the fallbackconfig.outputis absolute).