From fd59d36b249afbfe4d6b25b56442be57eb98a9e4 Mon Sep 17 00:00:00 2001 From: Garrett Stevens Date: Wed, 2 Dec 2020 14:50:33 -0700 Subject: [PATCH] fix: find yarn.lock in a yarn workspace (#156) --- package.json | 1 + src/tarballs/build.ts | 6 ++++-- yarn.lock | 7 +++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5443bb19..82fced9a 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@oclif/plugin-help": "^3.2.0", "cli-ux": "^5.2.1", "debug": "^4.1.1", + "find-yarn-workspace-root": "^2.0.0", "fs-extra": "^8.1", "github-slugger": "^1.2.1", "lodash": "^4.17.11", diff --git a/src/tarballs/build.ts b/src/tarballs/build.ts index bd969403..2a9bd221 100644 --- a/src/tarballs/build.ts +++ b/src/tarballs/build.ts @@ -1,5 +1,6 @@ import {ArchTypes, PlatformTypes} from '@oclif/config' import * as Errors from '@oclif/errors' +import * as findYarnWorkspaceRoot from 'find-yarn-workspace-root' import * as path from 'path' import * as qq from 'qqjs' @@ -52,9 +53,10 @@ export async function build(c: IConfig, options: { } const addDependencies = async () => { qq.cd(c.workspace()) - const yarn = await qq.exists.sync([c.root, 'yarn.lock']) + const yarnRoot = findYarnWorkspaceRoot(c.root) || c.root + const yarn = await qq.exists([yarnRoot, 'yarn.lock']) if (yarn) { - await qq.cp([c.root, 'yarn.lock'], '.') + await qq.cp([yarnRoot, 'yarn.lock'], '.') await qq.x('yarn --no-progress --production --non-interactive') } else { let lockpath = qq.join(c.root, 'package-lock.json') diff --git a/yarn.lock b/yarn.lock index a602b548..a04a55fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1471,6 +1471,13 @@ find-up@^4.0.0, find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" +find-yarn-workspace-root@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd" + integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ== + dependencies: + micromatch "^4.0.2" + flat-cache@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0"