Skip to content

Commit

Permalink
fix(add): Allow --registry option
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Oct 3, 2018
1 parent 25af71d commit 597606c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commands/add/README.md
Expand Up @@ -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 <url>`

Use a custom registry to install the targeted package.

## Examples

```sh
Expand Down
17 changes: 17 additions & 0 deletions commands/add/__tests__/add-command.test.js
Expand Up @@ -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");

Expand Down
6 changes: 6 additions & 0 deletions commands/add/command.js
Expand Up @@ -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-*",
Expand Down

0 comments on commit 597606c

Please sign in to comment.