diff --git a/commands/add/README.md b/commands/add/README.md index 4703b72ea2..bcef485903 100644 --- a/commands/add/README.md +++ b/commands/add/README.md @@ -33,6 +33,10 @@ $ lerna add --exact Add the new package with an exact version (e.g., `1.0.1`) rather than the default `^` semver range (e.g., `^1.0.1`). +### `--registry ` + +Use a custom registry to install the targeted package. + ## Examples ```sh diff --git a/commands/add/__tests__/add-command.test.js b/commands/add/__tests__/add-command.test.js index 926b74c5f3..b3387d29e6 100644 --- a/commands/add/__tests__/add-command.test.js +++ b/commands/add/__tests__/add-command.test.js @@ -187,6 +187,23 @@ describe("AddCommand", () => { expect(await readPkg(testDir, "packages/package-1")).toDependOn("tiny-tarball", "1.0.0", { exact: true }); }); + it("accepts --registry option", async () => { + const testDir = await initFixture("basic"); + + try { + await lernaAdd(testDir)( + "@my-own/private-idaho", + "--registry", + "http://registry.cuckoo-banana-pants.com/" + ); + } catch (err) { + // obviously this registry doesn't exist, thus it will always error + expect(err.message).toMatch("ENOTFOUND"); + } + + expect.assertions(1); + }); + it("should bootstrap changed packages", async () => { const testDir = await initFixture("basic"); diff --git a/commands/add/command.js b/commands/add/command.js index 6e4e5fea92..aa2dde3755 100644 --- a/commands/add/command.js +++ b/commands/add/command.js @@ -32,6 +32,12 @@ exports.builder = yargs => { alias: "exact", describe: "Save version exactly", }, + registry: { + group: "Command Options:", + describe: "Use the specified registry for all npm client operations.", + type: "string", + requiresArg: true, + }, }) .example( "$0 add module-1 packages/prefix-*",