Skip to content

fix: Windows support-exit 0 instead of true in scripts #171

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

Merged
merged 1 commit into from
Jan 15, 2025
Merged

fix: Windows support-exit 0 instead of true in scripts #171

merged 1 commit into from
Jan 15, 2025

Conversation

vadimpiven
Copy link
Contributor

@vadimpiven vadimpiven commented Jan 14, 2025

Support running git-clang-format on windows machines.

Summary

I am using Angular clang-format for formatting my C++ code used to build Node.js Native Addon. I want to support arm64 targets, and Angular clang-format only supports amd64 ones. I wanted to adopt git-clang-format in place of it as it bundles linux-arm64 and darwin-arm64 binaries (but not windows-arm64 which would also be highly appreciated).

I tried the following:

  1. Add clang-format-git as dev dependency
  2. Run npm i on windows machine

And got an error:

npm error command C:\WINDOWS\system32\cmd.exe /d /s /c test -d src && npm run build || npm run chmod
npm error > clang-format-git@1.2.3 chmod
npm error > find ./src/bin ./build/bin -type f -exec chmod 755 {} + || true
npm error 'test' is not recognized as an internal or external command,
npm error operable program or batch file.
npm error FIND: Parameter format not correct
npm error 'true' is not recognized as an internal or external command,
npm error operable program or batch file.

Details

The error originates from postinstall scripts, mainly from tail command || true. The error reproduces in both CMD and PowerShell. Current postinstall script runs successfully only in git-bash and WSL. But in my case I have to run npm i from Visual Studio Developer Console which is either CMD or PowerShell.

To fix the error || exit 0 could be used in place of || true as a windows-compatible alternative.

BTW I would highly appreciate if new version would be published to the npm registry after this change is merged, so I would be able to use this package :)

How did you test this change?

After the change I was able to successfully use package both from PowerShell and WSL.

Resolved Issues

Closes #170

@lumirlumir lumirlumir self-assigned this Jan 15, 2025
@lumirlumir lumirlumir added bug Something isn't working current: reviewing Currently reviewing it. labels Jan 15, 2025
@lumirlumir
Copy link
Owner

lumirlumir commented Jan 15, 2025

Hello, @vadimpiven

Thank you for submitting the issue and PR!

I’ll review this bug within the next 24 hours, so I kindly ask for your patience until then :)

Copy link

codecov bot commented Jan 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (8d6ad17) to head (16522df).
Report is 1 commits behind head on main.

@@            Coverage Diff            @@
##              main      #171   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           11        11           
  Lines          416       416           
=========================================
  Hits           416       416           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d6ad17...16522df. Read the comment docs.

@vadimpiven
Copy link
Contributor Author

BTW, I found the || exit 0 workaround here https://remysharp.com/2018/01/08/a-clean-exit so it is already used in the wild

@lumirlumir lumirlumir changed the title Windows support: 'exit 0' instead of 'true' in scripts fix: Windows support-exit 0 instead of true in scripts Jan 15, 2025
Copy link
Owner

@lumirlumir lumirlumir left a comment

Choose a reason for hiding this comment

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

@vadimpiven Thanks for the PR! It looks good to me.

I've reviewed it and confirmed that it is indeed a bug. The issue can be reproduced when using PowerShell or CMD.

The new version, v1.2.4, will be published within the next hour.


but not windows-arm64 which would also be highly appreciated

I previously attempted to support Windows-arm64 (Tier 2 in Node.js), but ran into limitations as neither the Docker image nor the GitHub Actions runner image support Windows-arm64. Unfortunately, this means it cannot currently be supported.

If you have any alternative ideas for enabling Windows-arm64 support, please feel free to open an issue. I'd be happy to review it!

@lumirlumir lumirlumir merged commit ec062f1 into lumirlumir:main Jan 15, 2025
33 checks passed
@vadimpiven
Copy link
Contributor Author

Thanks a lot!
Ok, will come back as soon as I will get my hands on arm64 windows machine))

@lumirlumir
Copy link
Owner

lumirlumir commented Jan 15, 2025

@vadimpiven 👍👍

Just a note: clang-format for Windows ARM64 should be buildable using GitHub Actions!

Reference: https://github.com/lumirlumir/npm-clang-format-node/blob/main/.github/workflows/llvm-build-bump-pr.yml


If it can't be built through GitHub Actions CI, it won't be acceptable.

Additionally, I tried using the assets built by LLVM (link), but since they can't guarantee stability(sometimes the binaries are missing) and security, they are also not acceptable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working current: reviewing Currently reviewing it. 🏷️ type: fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: clang-format-git does not work on windows
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy