symlinked
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ var symlinked = require("./") |
14
index.js
@@ -7,3 +7,3 @@ var fs = require("fs") | ||
function search(dir) { | ||
function search(dir, scope) { | ||
dir = dir || "." | ||
@@ -13,10 +13,14 @@ var context = path.resolve(dir) | ||
var contents = fs.readdirSync(context) | ||
return contents.map(function(name) { | ||
return contents.reduce(function (accumulated, name) { | ||
var relative = path.join(dir, name) | ||
var isScoped = name.charAt(0) === "@" | ||
if (isScoped) return accumulated.concat(search(relative, name)) | ||
var found = new Found | ||
found.name = name | ||
found.name = scope ? scope + "/" + name : name | ||
found.path = path.resolve(relative) | ||
if (scope) found.scope = scope | ||
if (is(relative)) found.link = read(relative) | ||
return found | ||
}) | ||
accumulated.push(found) | ||
return accumulated | ||
}, []) | ||
} | ||
@@ -23,0 +27,0 @@ |
@@ -0,0 +0,0 @@ ## ISC License |
{ | ||
"name": "symlinked", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Node utility to list packages that are npm linked", | ||
"main": "index.js", | ||
"bin": "bin.js", | ||
"scripts": { | ||
@@ -7,0 +8,0 @@ "demo": "node demo.js", |
# symlinked | ||
Node utility to list symlinks made by [`npm link`](https://docs.npmjs.com/cli/link), [`yarn link`](https://yarnpkg.com/lang/en/docs/cli/link/), or [`fs.link`](https://nodejs.org/api/fs.html) | ||
## Setup | ||
### Install via `npm` or `yarn` | ||
## Install | ||
``` | ||
@@ -10,6 +10,25 @@ npm install symlinked | ||
Local install as above is best practice if you are using in a shared codebase because then all developers will use the same version. CLI can be used locally via npx or via npm scripts. `npm install` has a `--global` flag you can add if you prefer global use. Yarn can be used via `yarn add` and `yarn global add` respectively if you prefer yarn. | ||
## CLI | ||
``` | ||
yarn add symlinked | ||
Usage: symlinked <command> [<path>] | ||
Finds all linked package names of an npm package. | ||
Commands: | ||
names Get linked package names | ||
paths Get linked package paths | ||
roots Get linked package roots | ||
links Get linked package links | ||
Options: | ||
-h, --help Display this usage info | ||
``` | ||
## API | ||
### `require` | ||
@@ -20,3 +39,3 @@ ```js | ||
## Methods | ||
### Methods | ||
- `symlinked.names(dir: ".")` get array of linked package names | ||
@@ -29,4 +48,4 @@ - `symlinked.paths(dir: ".")` get array of linked package paths | ||
## Examples | ||
### Ran in package directory with `said` dependency linked on both ends | ||
### Examples | ||
#### Ran in package directory with `said` dependency linked on both ends | ||
```js | ||
@@ -33,0 +52,0 @@ symlinked.names() |
@@ -0,0 +0,0 @@ var symlinked = require("./") |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8101
151
76