From 35b39dfc2298d52ef37a161370f8661390de7e85 Mon Sep 17 00:00:00 2001 From: Andrew Lisowski Date: Sun, 14 Mar 2021 12:07:48 -0700 Subject: [PATCH] better exclude for lerna private packages --- .../utils/__tests__/get-lerna-packages.test.ts | 16 +++++++++++++++- packages/core/src/utils/get-lerna-packages.ts | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/core/src/utils/__tests__/get-lerna-packages.test.ts b/packages/core/src/utils/__tests__/get-lerna-packages.test.ts index 9f22291dd..cffc0d9bf 100644 --- a/packages/core/src/utils/__tests__/get-lerna-packages.test.ts +++ b/packages/core/src/utils/__tests__/get-lerna-packages.test.ts @@ -7,7 +7,7 @@ jest.mock("../exec-promise"); // @ts-ignore execPromise.mockImplementation(exec); -test("it shouldn't included private packages", async () => { +test("it shouldn't included version-less packages", async () => { exec.mockReturnValue(endent` /dir/a:a:0.3.0--canary.32.d54a0c4.0 /dir/b:b:MISSING:PRIVATE @@ -20,3 +20,17 @@ test("it shouldn't included private packages", async () => { }, ]); }); + +test("it shouldn't included private packages", async () => { + exec.mockReturnValue(endent` + /dir/a:a:0.3.0--canary.32.d54a0c4.0 + /dir/b:b:0.3.0:PRIVATE + `); + expect(await getLernaPackages()).toStrictEqual([ + { + name: "a", + path: "/dir/a", + version: "0.3.0--canary.32.d54a0c4.0", + }, + ]); +}); diff --git a/packages/core/src/utils/get-lerna-packages.ts b/packages/core/src/utils/get-lerna-packages.ts index 7d654ce6f..93748046a 100644 --- a/packages/core/src/utils/get-lerna-packages.ts +++ b/packages/core/src/utils/get-lerna-packages.ts @@ -15,9 +15,9 @@ export default async function getLernaPackages() { const response = await execPromise("npx", ["lerna", "ls", "-pla"]); response.split("\n").forEach((packageInfo) => { - const [packagePath, name, version] = packageInfo.split(":"); + const [packagePath, name, version, isPrivate] = packageInfo.split(":"); - if (version !== "MISSING") { + if (version !== "MISSING" && isPrivate !== "PRIVATE") { packages.push({ path: packagePath, name, version }); } });