Check whether the working directory prefers yarn over npm
npm install prefers-yarn
const prefersYarn = require('prefers-yarn') const useYarn = prefersYarn() // boolean if (useYarn) { // do stuff }
MIT (c) Cezar Augusto.