Skip to content

Commit

Permalink
Preserve linked packages in create command (yarnpkg#7543)
Browse files Browse the repository at this point in the history
* Preserve linked packages in create command

* Update changelog

* Warn when using linked package

* Update CHANGELOG.md

* Update link-resolver.js
  • Loading branch information
nickmccurdy authored and Vincent Bailly committed Jun 10, 2020
1 parent 26350bc commit 635a544
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
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

0 comments on commit 635a544

Please sign in to comment.