3

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 manual bug regarding using Linux command in 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

vitaliy4us
  • 483
  • 5
  • 21
  • You can use the `del` command, or just open the directory in explorer and delete it's contents. – Evert Aug 14 '21 at 04: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 Aug 14 '21 at 04:44
  • Could you just switch to using `bash`? It works on windows. Another great option WSL. Super recommended for Javascript development. – Evert Aug 14 '21 at 04: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 Aug 14 '21 at 05: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 Aug 15 '21 at 03:08

1 Answers1

3

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",
Eddy Gilmour
  • 860
  • 2
  • 13
  • 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 Aug 14 '21 at 05:30
  • I think so, but have not tried on linux - works on Windows. From this question [How to run rm command on windows 10](https://stackoverflow.com/a/41452647/16616693) – Eddy Gilmour Aug 14 '21 at 05:31
  • Further note, yes because these are packages using nodejs which has built-in cross platform. – Eddy Gilmour Aug 14 '21 at 05:33
  • You're welcome. Thank you for question, I'm just starting docker - will need it too. – Eddy Gilmour Aug 14 '21 at 05:55