Skip to content

Commit

Permalink
Fix private packages (#28)
Browse files Browse the repository at this point in the history
* Move tests around

* Update snap

* Finish spec

* Error when dependency package is not published
Fixes #19

* Only skip private packages

* Update command comment
  • Loading branch information
mskelton authored Aug 29, 2021
1 parent 8f8aae6 commit 95136ea
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bundles/@yarnpkg/plugin-outdated.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/OutdatedCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ export class OutdatedCommand extends BaseCommand {
): Promise<OutdatedDependency[]> {
const outdated = dependencies.map(
async ({ dependencyType, name, pkg, workspace }) => {
// If the dependency is a workspace, then we don't need to check
// if it is outdated. These type of packages tend to be versioned with
// a tool like Lerna or they are private.
if (workspace.project.tryWorkspaceByLocator(pkg)) {
return
}

const { url, version: latest } = await fetcher.fetch({
pkg,
range: "latest",
Expand Down
20 changes: 20 additions & 0 deletions test/specs/outdated.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,24 @@ test.describe("yarn outdated", () => {
expect(stdout).toMatchSnapshot("resolutions.txt")
expect(stderr).toBe("")
})

test("skips private packages", async ({ env }) => {
const { run, writeJSON } = env

await writeJSON("package.json", { workspaces: ["packages/*"] })
await writeJSON("packages/a/package.json", {
name: "a",
private: true,
version: "1.1.0",
})
await writeJSON("packages/b/package.json", {
dependencies: { a: "1.1.0", patch: "1.0.0" },
name: "b",
})
await run("install")

const { stderr, stdout } = await run("outdated --all")
expect(stdout).toMatchSnapshot("private.txt")
expect(stderr).toBe("")
})
})
8 changes: 8 additions & 0 deletions test/specs/outdated.spec.ts-snapshots/private.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
➤ YN0000: ┌ Checking for outdated dependencies
➤ YN0000: └ Completed

➤ YN0000: Package Current Latest Workspace Package Type
➤ YN0000: patch 1.0.0 1.0.1 b dependencies

➤ YN0000: 1 dependency is out of date
➤ YN0000: Done with warnings

0 comments on commit 95136ea

Please sign in to comment.