Multi-tool builds - Composer and Yarn

I have what should be a fairly simple build that I’m struggling to get working.

At the root of my project I have /composer.json and /composer.lock
In a subfolder of my project I have yarn.lock file (/docroot/themes/mytheme/yarn.lock)

What I’d like to happen it that the build does the following:

composer install
cd /docroot/themes/mytheme/
yarn install
yarn run build

It should then publish /docroot/themes/mytheme/pattern-lab/public

However, if yarn.lock is not in the root of my project then the yarn command is not available.

Is there an easy way around this?

You’d have to install yarn to use it, like everything else in our builds. We do automatically guess that you need it if we find /yarn.lock, as you’ve noticed. You could drop a package.json in the root of your repo, just to install yarn, though that’s a hack (like all of my advice - we really intend for you to point us to where yarn.lock is. Maybe you could just move it to the root of your repo? Packages installed should be usable from any path. That would be the “best” solution.)

But even if you do none of that, this might work as a build command:

composer install && npm i yarn && cd docroot/themes/mytheme && yarn install && yarn run build