2

Cypress manual for configuring Reporters contains rm command which doesn't work in Windows, namely

rm cypress/results/* || true

I believe that this is the bug in the documentation, which advises using a Linux command in the Windows environment.

So the question is how it can be done in Windows? Moreover, I suppose to use the config file containing this command in Docker container which uses Linux core I believe. So the another problem is if I convert the command for Windows will I be able to use this file in my Docker container? Could somebody point me out the right way of using this command for the both OS? here is the link to Cypress manual containing this command https://docs.cypress.io/guides/tooling/reporters#Examples

5
  • You can use the del command, or just open the directory in explorer and delete it's contents.
    – Evert
    Commented Aug 14, 2021 at 4:15
  • Yes, I tried it but it does not work. As I said the command must be somehow converted to do the same as the Linux command does. The simple replacing rm with del does not work
    – vitaliy4us
    Commented Aug 14, 2021 at 4:44
  • Could you just switch to using bash? It works on windows. Another great option WSL. Super recommended for Javascript development.
    – Evert
    Commented Aug 14, 2021 at 4:51
  • Yes I agree WSL is a great feature, but as I said I have to use the command in config file. It is not for manual use. And one more very important thing I missed here. I need to use rm with -r option which makes del and rm different as del does not have such kind of option allowing to delete not only files but also directories recursively
    – vitaliy4us
    Commented Aug 14, 2021 at 5:21
  • Yes but you are running everything from cmd.exe. If you switch to WSL you can just run everything in bash and commands like rm will just be available exactly as you expect.
    – Evert
    Commented Aug 15, 2021 at 3:08

1 Answer 1

4

rmdir can be used in windows

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

I do not think this will work for docker.


Cross platform,

yarn add -D rimraf mkdirp

"delete:reports": "rimraf cypress/results && mkdirp cypress/results",
4
  • Great! Thank you! Sorry, but could you please clarify cross platform usage? Will it be enough to use this command in my config file "delete:reports": "rimraf cypress/results && mkdirp cypress/results"
    – vitaliy4us
    Commented Aug 14, 2021 at 5:30
  • I think so, but have not tried on linux - works on Windows. From this question How to run rm command on windows 10 Commented Aug 14, 2021 at 5:31
  • Further note, yes because these are packages using nodejs which has built-in cross platform. Commented Aug 14, 2021 at 5:33
  • You're welcome. Thank you for question, I'm just starting docker - will need it too. Commented Aug 14, 2021 at 5:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.