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

npm scripts for windows #4607

Closed
wants to merge 2 commits into from
Closed

Conversation

math-GH
Copy link
Contributor

@math-GH math-GH commented Sep 12, 2022

Ref #4602

The npm scripts (package.json) does not work on a Windows 10 machine.

So I started to investigate how to run it on Windows.

Here is my solution draft. Not complete yet. See it as proof of concept.

@math-GH
Copy link
Contributor Author

math-GH commented Sep 12, 2022

A little explanation:

the package.json has some unescaped ' character that CMD/Powershell does not like.

So I created a copy of package.json -> package-windows.json that improves it for the usage on Windows.

runscripts.bat renames the package.json to another temp name and package-windows.json -> package.json and runs then the npm scripts.
At the end it renames it back.

It works fine:
grafik

"url": "https://github.com/FreshRSS/FreshRSS.git"
},
"license": "AGPL-3.0",
"scripts": {
Copy link
Member

Choose a reason for hiding this comment

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

instead of a new file, you could have just the scripts that require a Windows-specific command, e.g. "stylelint_win"

Copy link
Member

Choose a reason for hiding this comment

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

And maybe we can find a syntax that works on both platforms

Copy link
Member

Choose a reason for hiding this comment

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

I suspect the syntax as written is already a syntax that works on both platforms. I probably just used native shell instead because it's more intuitive. Cf. https://www.npmjs.com/package/fast-glob which is used by Stylelint. (I don't have npm set up on this laptop.)

Copy link
Member

Choose a reason for hiding this comment

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

Put another way, just change that single line in the original file, introduce an error and see if the CI catches it.

Copy link
Member

Choose a reason for hiding this comment

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

No, the syntax without the quotes does not work in Bash, but another syntax might be possible

"eslint_fix": "eslint --fix --ext .js .",
"markdownlint": "markdownlint '**/*.md'",
"markdownlint_fix": "markdownlint --fix '**/*.md'",
"rtlcss": "rtlcss -d p/themes/ && find p/themes/ -type f -name '*.rtl.rtl.css' -delete",
Copy link
Member

Choose a reason for hiding this comment

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

I am afraid other things would not work on DOS-style command-line anyway, such as this command using find. But all that works fine on Windows with WSL.

@math-GH math-GH closed this Mar 21, 2024
@math-GH math-GH deleted the scripts-for-windows branch March 21, 2024 21:02
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.

3 participants