Skip to content

Commit

Permalink
fix(core): prevent validation error in version/publish with `workspac…
Browse files Browse the repository at this point in the history
…e:` prefix (#3322)
  • Loading branch information
fahslaj committed Sep 8, 2022
1 parent 674ffd3 commit 746ce33
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
33 changes: 0 additions & 33 deletions core/package-graph/__tests__/package-graph.test.js
Expand Up @@ -300,31 +300,6 @@ describe("PackageGraph", () => {
`"Package specification \\"test-1@^1.1.0\\" could not be resolved within the workspace. To reference a non-matching, remote version of a local dependency, remove the 'workspace:' prefix."`
);
});

it("throws an error when sibling package does not exist in the workspace, regardless of version specification", () => {
const packages = [
new Package(
{
name: "test-1",
version: "1.0.0",
},
"/test/test-1"
),
new Package(
{
name: "test-2",
version: "1.0.0",
dependencies: {
"test-3": "workspace:^1.0.0",
},
},
"/test/test-2"
),
];
expect(() => new PackageGraph(packages)).toThrowErrorMatchingInlineSnapshot(
`"Package specification \\"test-3@^1.0.0\\" could not be resolved within the workspace. To use the 'workspace:' protocol, ensure that a package with name \\"test-3\\" exists in the current workspace."`
);
});
});
});

Expand Down Expand Up @@ -621,14 +596,6 @@ Set {
});
});

// eslint-disable-next-line no-unused-vars
function deepInspect(obj) {
// jest console mutilates console.dir() options argument,
// so sidestep it by requiring the non-shimmed method directly.
// eslint-disable-next-line global-require
require("console").dir(obj, { depth: 10, compact: false });
}

function topoPackages() {
return [
{
Expand Down
7 changes: 0 additions & 7 deletions core/package-graph/index.js
Expand Up @@ -73,13 +73,6 @@ class PackageGraph extends Map {
fullWorkspaceSpec = spec;
spec = spec.replace(/^workspace:/, "");

if (!depNode) {
throw new ValidationError(
"EWORKSPACE",
`Package specification "${depName}@${spec}" could not be resolved within the workspace. To use the 'workspace:' protocol, ensure that a package with name "${depName}" exists in the current workspace.`
);
}

// replace aliases (https://pnpm.io/workspaces#referencing-workspace-packages-through-aliases)
if (spec === "*" || spec === "^" || spec === "~") {
workspaceAlias = spec;
Expand Down

0 comments on commit 746ce33

Please sign in to comment.