### npm-link-extra

* * *

Some useful things we wish npm/yarn link had. Inspired by fs-extra...

One issue currently is the inconsistency between npm's link behavior between the major versions. We have found link to be most stable with version 3.10.10 so that is our recommended npm version.

### Install

```bash
$ npm install npm-link-extra --save-dev
```

### CLI Docs

```bash
Usage
  $ nlx <path> -<cmd> --<options>
  $ npx nlx <path> -<cmd> --<options>
Commands
  -h, --help        show help menu
  -l, --link        link all dirs if present in dependencies
  -u, --unlink      unlink all linked dependencies
  -s, --show        show all shared and/or linked dependencies
  -v, --version     get npm-link-extra package version
Options
  -d, --dir         relative path to mononrepo/dir with many modules
  --linked-only     only select currently linked packages
  --shared-only     only select shared dependencies between project and target dir
```

### Documentation

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

##### Table of Contents

-   [getDirectories](#getdirectories)
    -   [Parameters](#parameters)
-   [getPackages](#getpackages)
    -   [Parameters](#parameters-1)
-   [getSharedDepDirs](#getshareddepdirs)
    -   [Parameters](#parameters-2)
-   [getSharedLinked](#getsharedlinked)
    -   [Parameters](#parameters-3)
-   [getSharedDeps](#getshareddeps)
    -   [Parameters](#parameters-4)
-   [getLinkedDeps](#getlinkeddeps)
    -   [Parameters](#parameters-5)

#### getDirectories

getDirectories returns all directories in a given path

##### Parameters

-   `pathTo` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** relative path to monorepo or directory with node modules
-   `opts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** options to call the function with

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array of directories

#### getPackages

getPackages returs all packages

##### Parameters

-   `dirs` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array of directories

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** array of packages & the relative path to them

#### getSharedDepDirs

getSharedDepDirs selects an array of shared and linked packages

##### Parameters

-   `pkgs` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** An array of dependencies
-   `hash` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** A hash map of our deps

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** A filtered list of shared pkg dirs

#### getSharedLinked

getSharedLinked selects an array of shared and linked packages

##### Parameters

-   `pkgs` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** An array of dependencies
-   `hash` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** A hash map of our deps

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** A filtered list of packages

#### getSharedDeps

getSharedDeps will show any shared dependencies between project & target dir

##### Parameters

-   `pkgs` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** An array of dependencies
-   `hash` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** A hash map of our deps

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of shared dep names

#### getLinkedDeps

getLinkedDeps returns a list of linked dependencies

##### Parameters

-   `pkgs` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** An array of dependencies

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of linked dep names
