Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): allow paths inside the workspace: protocol to start with ./ #1722

Merged
merged 1 commit into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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