# mothership

> Helps a module find its package.json mothership.

Latest version **0.3.0** (published 2014-04-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install mothership
pnpm add mothership
yarn add mothership
bun add mothership
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2014-04-01 |
| First published | 2014-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Thorsten Lorenz |
| Maintainers | thlorenz |
| Keywords | find, resolve, package.json, condition, predicate, root |

## Links

- npm: https://www.npmjs.com/package/mothership
- Repository: https://github.com/thlorenz/mothership
- Issues: https://github.com/thlorenz/mothership/issues
- npm.io page: https://npm.io/package/mothership

## Dependencies (1)

- [find-parent-dir](https://npm.io/package/find-parent-dir.md) ~0.3.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.3.0 (latest) — 2014-04-01
- 0.2.0 — 2014-03-29
- 0.1.0 — 2014-02-24

## README

# mothership [![build status](https://secure.travis-ci.org/thlorenz/mothership.png)](http://travis-ci.org/thlorenz/mothership)

Helps a module find its `package.json` mothership.

```js
var mothership = require('mothership')
  , path = require('path');

mothership(
    path.join(__dirname, 'uno', 'dos', 'tres')
  , function ismothership (pack) {
      return !!(pack.dependencies && pack.dependencies.unodep);
    }
  , function (err, res) {
      if (err) return console.error(err);
      console.log('first mothership', res.path);  // => [..]/example/uno/package.json
  }
)

// Synchronous
var res = mothership.sync(
    path.join(__dirname, 'uno', 'dos', 'tres')
  , function ismothership (pack) {
      return !!(pack.dependencies && pack.dependencies.unodep);
    }
)      

console.log('found mothership', res.path);  // => [..]/example/uno/package.json
```

## Installation

    npm install mothership

## API

<!-- START docme generated API please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN docme TO UPDATE -->

<div>
<div class="jsdoc-githubify">
<section>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<dl>
<dt>
<h4 class="name" id="mothership"><span class="type-signature"></span>mothership<span class="signature">(start, ismothership, cb)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>Searches upwards from start for package.json files, asking for each if it is the mothership.
If a mothership is found it calls back with that.
If it reaches the top of the univers it calls back with nothing.</p>
<h5>mothership result</h5>
<ul>
<li><code>path</code>: full path to the <code>package.json</code> that is the mother ship</li>
<li><code>pack</code>: the <code>package.json</code> object, same that was passed to ismothership</li>
</ul>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>full path at which to start looking for the mothership</p></td>
</tr>
<tr>
<td class="name"><code>ismothership</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"><p>invoked with the package object, needs to return true if it is the mothership</p></td>
</tr>
<tr>
<td class="name"><code>cb</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"><p>called back with either an error or full path to package.json that is the mothership</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy">
<li>
<a href="https://github.com/thlorenz/mothership/blob/master/index.js">index.js</a>
<span>, </span>
<a href="https://github.com/thlorenz/mothership/blob/master/index.js#L8">lineno 8</a>
</li>
</ul></dd>
</dl>
</dd>
<dt>
<h4 class="name" id="mothership::sync"><span class="type-signature"></span>mothership::sync<span class="signature">(start, ismothership)</span><span class="type-signature"> &rarr; {string}</span></h4>
</dt>
<dd>
<div class="description">
<p>Synchronous version of mothership.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>start</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>full path at which to start looking for the mothership</p></td>
</tr>
<tr>
<td class="name"><code>ismothership</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last"><p>invoked with the package object, needs to return true if it is the mothership</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy">
<li>
<a href="https://github.com/thlorenz/mothership/blob/master/index.js">index.js</a>
<span>, </span>
<a href="https://github.com/thlorenz/mothership/blob/master/index.js#L42">lineno 42</a>
</li>
</ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>full path to package.json that is the mothership or <code>null</code> if it wasn't found</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>

*generated with [docme](https://github.com/thlorenz/docme)*
</div>
<!-- END docme generated API please keep comment here to allow auto update -->

## License

MIT

---
_Source: https://npm.io/package/mothership · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
