Skip to content

Commit

Permalink
fix(core): allow paths inside the workspace: protocol to start with ./ (
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-soporan committed Aug 20, 2020
1 parent 8c82779 commit e5bc305
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 32 deletions.
30 changes: 30 additions & 0 deletions .yarn/versions/b175cbd5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
releases:
"@yarnpkg/cli": prerelease
"@yarnpkg/core": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-node-modules"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/doctor"
- "@yarnpkg/pnpify"
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- The progress bars will be properly styled when using the new Windows terminal on certain days.
- Yarn will now avoid using deprecated versions of the dependencies, unless only deprecated versions are available for the requested ranges.
- Build keys are now properly computed, which fixes issues where build scripts weren't always triggered when they should have been.
- Yarn will now allow relative paths inside the `workspace:` protocol to start with `./`

### CLI

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {PortablePath} from '@yarnpkg/fslib';
import {fs} from 'pkg-tests-core';

const {writeJson} = fs;

describe(`Protocols`, () => {
describe(`workspace:`, () => {
test(
`it should recognize prereleases in wildcard ranges`,
makeTemporaryEnv(
{
private: true,
workspaces: [`docs`, `components`],
},
async ({path, run, source}) => {
await writeJson(`${path}/docs/package.json` as PortablePath, {
name: `docs`,
private: true,
dependencies: {
components: `workspace:*`,
},
});
await writeJson(`${path}/components/package.json` as PortablePath, {
name: `components`,
version: `1.0.0-alpha.0`,
});

await expect(run(`install`)).resolves.toBeTruthy();
},
),
);

test(
`it should support relative paths (without ./)`,
makeTemporaryMonorepoEnv({
workspaces: [`packages/*`],
dependencies: {
[`foo`]: `workspace:packages/foo`,
},
}, {
[`packages/foo`]: {
name: `foo`,
},
}, async ({path, run, source}) => {
await expect(run(`install`)).resolves.toBeTruthy();
})
);

test(
`it should support relative paths (with ./)`,
makeTemporaryMonorepoEnv({
workspaces: [`packages/*`],
dependencies: {
[`foo`]: `workspace:./packages/foo`,
},
}, {
[`packages/foo`]: {
name: `foo`,
},
}, async ({path, run, source}) => {
await expect(run(`install`)).resolves.toBeTruthy();
})
);
});
});
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/Workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class Workspace {
? range.slice(protocolIndex + 1)
: range;

if (protocol === WorkspaceResolver.protocol && pathname === this.relativeCwd)
if (protocol === WorkspaceResolver.protocol && ppath.normalize(pathname as PortablePath) === this.relativeCwd)
return true;

if (protocol === WorkspaceResolver.protocol && pathname === `*`)
Expand Down

0 comments on commit e5bc305

Please sign in to comment.