Linux – How do I convert rm commands for Windows environments?

How do I convert rm commands for Windows environments?… here is a solution to the problem.

How do I convert rm commands for Windows environments?

The Cypress manual for configuring Reporters contains rm commands that don’t work in Windows, ie

rm cypress/results/* || True

I believe this is a manual bug about using Linux commands in a Windows environment, so the question is how to do it in Windows? Also, I want to use a config file that contains this command in a Docker container that I believe is using the Linux kernel. So another question is, if I convert commands for Windows, will I be able to use this file in my Docker container? Can someone point me to the right way to use this command for these two operating systems? Here is a link to the Cypress manual that contains this command https://docs.cypress.io/guides/tooling/reporters#Examples

Solution

RMDIR is available under Windows

"delete:reports": "rmdir /S /Q cypress\\results && mkdir cypress\\results",

I don’t think this works for docker.


Cross-platform

yarn add -D rimraf mkdirp

"delete:reports": "rimraf cypress/results && mkdirp cypress/results",

Related Problems and Solutions