[Repo Assist] improve: extract resolveWorkspacePath utility; fix relative standard paths#139
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…paths
- Add resolveWorkspacePath() to lib/utils.js that handles ~ expansion,
${workspaceFolder}/${workspaceRoot} substitution, and relative path
resolution against the workspace root.
- Refactor loadSettings() to use resolveWorkspacePath() for the standard
setting, fixing #38 (relative paths like ./ruleset.xml in phpcbf.standard
were silently passed through instead of being resolved).
- Add 10 unit tests for resolveWorkspacePath (17 total, all pass).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
66 tasks
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Extracts a new
resolveWorkspacePath()utility inlib/utils.jsand uses it to resolve thephpcbf.standardsetting, fixing the case where relative paths (e.g../ruleset.xml) were silently passed through to phpcbf unchanged.Closes #38 (partially —
./ruleset.xmlinphpcbf.standardnow resolves to an absolute path against the workspace root).Root Cause
loadSettings()already handled\$\{workspaceFolder}/\$\{workspaceRoot}substitution for thestandardsetting, but it did not resolve relative paths like./ruleset.xmlorvendor/standard/ruleset.xml. These were passed directly to phpcbf, which then failed because phpcbf receives a temp-file path as the document and has no notion of the VS Code workspace root.Changes
lib/utils.jsresolveWorkspacePath(inputPath, rootPath)— handles~expansion,\$\{workspaceFolder}/\$\{workspaceRoot}substitution, and relative-path resolutionextension.jsloadSettings()with a call toresolveWorkspacePath()test/unit.test.jsresolveWorkspacePath(17 total; all pass)resolveWorkspacePathbehaviour./ruleset.xml/workspace/workspace/ruleset.xmlvendor/bin/standard/workspace/workspace/vendor/bin/standard\$\{workspaceFolder}/phpcs.xml/workspace/workspace/phpcs.xml\$\{workspaceRoot}/phpcs.xml/workspace/workspace/phpcs.xml~/.phpcs.xml(homedir)/.phpcs.xml/absolute/path.xml/absolute/path.xml(unchanged)./relative.xmlnull./relative.xml(unchanged, no root)Trade-offs
executablePathis handled and with user expectation.executablePath, custom standards from a config file) can use the same function.Test Status