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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve linked packages in create command #7543

Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Preserves linked packages when calling `yarn create`

[#7543](https://github.com/yarnpkg/yarn/pull/7543) - [**Nick McCurdy**](https://github.com/nickmccurdy)

- Fixes the offline mirror filenames when using Verdaccio

[#7499](https://github.com/yarnpkg/yarn/pull/7499) - [**xv2**](https://github.com/xv2)
Expand Down
9 changes: 8 additions & 1 deletion src/cli/commands/create.js
Expand Up @@ -5,6 +5,7 @@ import {MessageError} from '../../errors.js';
import type {Reporter} from '../../reporters/index.js';
import * as child from '../../util/child.js';
import {makeEnv} from '../../util/execute-lifecycle-script';
import * as fs from '../../util/fs.js';
import {run as runGlobal, getBinFolder} from './global.js';

const path = require('path');
Expand Down Expand Up @@ -58,7 +59,13 @@ export async function run(config: Config, reporter: Reporter, flags: Object, arg
}

const {fullName: packageName, name: commandName} = coerceCreatePackageName(builderName);
await runGlobal(config, reporter, {}, ['add', packageName]);

const linkLoc = path.join(config.linkFolder, commandName);
if (await fs.exists(linkLoc)) {
reporter.info(reporter.lang('linkUsing', packageName));
} else {
await runGlobal(config, reporter, {}, ['add', packageName]);
}

const binFolder = await getBinFolder(config, {});
const command = path.resolve(binFolder, commandName);
Expand Down
7 changes: 4 additions & 3 deletions src/resolvers/exotics/link-resolver.js
Expand Up @@ -30,9 +30,10 @@ export default class LinkResolver extends ExoticResolver {
const name = path.basename(loc);
const registry: RegistryNames = 'npm';

const manifest: Manifest = !await fs.exists(`${loc}/package.json`) || loc === this.config.lockfileFolder
? {_uid: '', name, version: '0.0.0', _registry: registry}
: await this.config.readManifest(loc, this.registry);
const manifest: Manifest =
!await fs.exists(`${loc}/package.json`) || loc === this.config.lockfileFolder
? {_uid: '', name, version: '0.0.0', _registry: registry}
: await this.config.readManifest(loc, this.registry);

manifest._remote = {
type: 'link',
Expand Down