Skip to content
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

Use a script to proxy PNPM executable on Windows #1116

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

jonkoops
Copy link
Contributor

@jonkoops jonkoops commented Oct 23, 2023

Since Windows does not support symbolic links (or at least not consistently), the choice was made not to support the PNPM executable under Windows. This PR adds support for running the PNPM executable by adding a script under the same name in the installation directory, and proxy any commands sent to it to the PNPM executable.

This also allow the removal of some of the testing profiles that were previously added as the tests would not pass under Windows. And also removes the legacy linking code that was copied from the NPM version that never worked.

Closes #1115

Comment on lines -178 to -193
for (String script : Arrays.asList("pnpm", "pnpm.cmd")) {
File scriptFile = new File(pnpmDirectory, "bin" + File.separator + script);
if (scriptFile.exists()) {
File copy = new File(installDirectory, script);
if (!copy.exists()) {
try
{
FileUtils.copyFile(scriptFile, copy);
}
catch (IOException e)
{
throw new InstallationException("Could not copy pnpm", e);
}
copy.setExecutable(true);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed this old code as it seems to have been copied from the NpmInstaller, but never actually functioned. I've manually checked every release of PNPM, and none of them include a pnpm or pnpm.cmd file in their bin directory.

Comment on lines +224 to +234
String scriptContents = new StringBuilder()
.append(":: Created by frontend-maven-plugin, please don't edit manually.\r\n")
.append("@ECHO OFF\r\n")
.append("\r\n")
.append("SETLOCAL\r\n")
.append("\r\n")
.append(String.format("SET \"NODE_EXE=%%~dp0\\%s\"\r\n", relativeNodePath))
.append(String.format("SET \"PNPM_CLI_JS=%%~dp0\\%s\"\r\n", relativePnpmPath))
.append("\r\n")
.append("\"%NODE_EXE%\" \"%PNPM_CLI_JS%\" %*")
.toString();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This script is partially taken from the NPM equivalent, but pruned down to the bare essentials needed for this use-case.

@jonkoops jonkoops changed the title Use a batch file to link PNPM executable on Windows Use a script to proxy PNPM executable on Windows Oct 23, 2023
@jonkoops
Copy link
Contributor Author

Looks like the tests on Windows are flaking out on something unrelated to the changes in this PR? Perhaps a re-run will pass them.

@eirslett
Copy link
Owner

Looks like it works. Thanks!

@eirslett eirslett merged commit 436bd91 into eirslett:master Oct 23, 2023
3 checks passed
@jonkoops jonkoops deleted the fix-pnpm-bin branch October 24, 2023 07:24
@jonkoops
Copy link
Contributor Author

Thanks for getting to this so quick @eirslett, much appreciated.

@eirslett
Copy link
Owner

Could you please help update the changelog as well? I think this will be released as a patch version.

@jonkoops
Copy link
Contributor Author

Sure, opened a PR under #1117

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.

PNPM executable not exposed on Windows
2 participants