async function installWithYarn (cwd, task) {
  const subprocess = execa('yarn', defaultArgs.yarn, { stdio, cwd })

  if (!task) return subprocess

  return new Promise((resolve, reject) => {
    const onRecievedData = (buffer) => {
      let str = buffer.toString().trim()

      if (str && str.includes('"type":')) {
        const newLineIndex = str.lastIndexOf('\n')

        if (newLineIndex !== -1) {
          str = str.substr(newLineIndex)
        }

        try {
          const { type, data } = JSON.parse(str)
          if (type === 'step') {
            const { message, current, total } = data

            task.setStatus(`${message} (${current} of ${total})`)

            if (current === total) {
              resolve()
            }
          } else if (type === 'error') {
            reject(new Error(data))
          }
        } catch (e) {}
      }
    }

    subprocess.stderr.on('data', onRecievedData)
    subprocess.stdout.on('data', onRecievedData)
  })
}
@param {string} cwd
@param {any} task