Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thlorenz/mothership
Helps a module find its package.json mothership.
https://github.com/thlorenz/mothership
Last synced: 15 days ago
JSON representation
Helps a module find its package.json mothership.
- Host: GitHub
- URL: https://github.com/thlorenz/mothership
- Owner: thlorenz
- License: mit
- Created: 2014-02-24T22:06:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-11T10:14:48.000Z (over 9 years ago)
- Last Synced: 2024-10-18T00:54:37.784Z (20 days ago)
- Language: JavaScript
- Homepage: https://github.com/thlorenz/mothership
- Size: 232 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
mothership(start, ismothership, cb)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.mothership result
path
: full path to thepackage.json
that is the mother shippack
: thepackage.json
object, same that was passed to ismothershipParameters:
Name
Type
Description
start
string
full path at which to start looking for the mothership
ismothership
function
invoked with the package object, needs to return true if it is the mothership
cb
function
called back with either an error or full path to package.json that is the mothership
mothership::sync(start, ismothership) → {string}Synchronous version of mothership.
Parameters:
Name
Type
Description
start
string
full path at which to start looking for the mothership
ismothership
function
invoked with the package object, needs to return true if it is the mothership
Returns:
full path to package.json that is the mothership or
null
if it wasn't found
Type
string*generated with [docme](https://github.com/thlorenz/docme)*
## License
MIT