Skip to content

Make ms-vscode.live-server an optional dependency #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Gerrit0
Copy link

@Gerrit0 Gerrit0 commented Jun 4, 2025

Removes hard dependency on live-server extension, replacing it with an error message if the preview command is used when not installed.

Resolves #392

test/runTest.ts Outdated
// Add the dependent extension for test coverage preview functionality
const vscodeExecutablePath = await downloadAndUnzipVSCode("insiders");
const [cliPath, ...args] = resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath);
// Ensure live-server is not installed
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not much of a fan of this as it means that we end up running all the tests twice, so this roughly doubles the amount of time it takes to run the tests, but wasn't able to find a better way of running a test without the live server extension installed...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wrap const livePreview = extensions.getExtension("ms-vscode.live-server"); in a function, you can stub that function in a couple of tests and get rid of all of this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or leave it installed and only stub it being missing in one test

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a much better idea! Implemented. I had to partially merge in your #482 branch in order to implement this


// Useful for debugging failing dependant extension installs
console.info(output);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The runVSCodeCommand function will throw if calling VSCode fails, so this will be caught by the catch block now

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! This is a super nice cleanup 🦾 .

@Gerrit0 Gerrit0 requested a review from mattseddon July 8, 2025 02:59
@mattseddon mattseddon requested a review from ryanluker July 8, 2025 03:14
@ryanluker
Copy link
Owner

@Gerrit0 Thanks for the PR and thanks @mattseddon for reviewing it, looking great so far.

I merged the other PR with the test changes / fixups, so I have rerun the CI action for yeah Gerrit.

await window.showErrorMessage("Live Preview extension not installed", {
modal: true,
detail: "The ms-vscode.live-server extension must be installed to preview the coverage report."
}, "Ok");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor thought: I have never had to do multiple languages for the extension, do we need to support that for the errors or is it more of a "nice to have"?

Copy link
Author

@Gerrit0 Gerrit0 Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Does this extension really need Live Preview?
3 participants