Why does this composite yarn build script not change directories

I have a yarn build script:

“rm -rf build && cd …/xyz-core && yarn build && cd …/client && cross-env CLIENT_ENV=development craco build”

I do this as I need to build a core library every time I deploy before I build the client (as its a dependency in the client code). This works fine on my local but when I run it in render I get an error saying “can’t find client directory” which means the cd command don’t seem to be working like they do in bash. I’m a newbie on the production deploy side so maybe i’m missing something. Render seems to remove the && and replace them with & like this:

“rm -rf build & cd …/xyz-core & yarn build & cd …/client & cross-env CLIENT_ENV=development craco build”

Maybe that affects it as well (and i’m not sure why it does that as && and & are different things). Any ideas here including how to solve the original problem of building a core library before I build the client?

Thanks!
Niel

  1. & and && do very different things. One of them runs a command in the background, the other is a control flow that only executes if the previous command exited successfully.
  2. cd ... will fail because you are not likely to have a directory named .... In Linux:
    • . means current directory
    • .. means the parent directory (if you’re in /foo/bar, then .. is /foo)
    • Any other number of dots is a literal directory name like build or client or xyz-core

Hi Jason,

  1. Understood. An issue I hit was Render was turning my && into & for some reason (the deploy logs showed this). I took everything from my package.json and put it into a shell script to run and that stopped that happening for whatever reason.

  2. Yup sorry that was a typo on my part (it should have been …). The problem I ran into is that when you link libraries using yarn link it creates symbolic links which don’t seem to work for Render services deployments (e.g. my node deploy environment). I ended up yarn pack-ing my library and adding it to my package.json as a file reference instead inline in my shell script and that got around it.

I finally got everything up and running this morning. I’m new to dev ops so a lot of this stuff may just be obvious after i’ve been doing it for years.

Thanks for taking the time to reply.