resolve-locals.js

0.0.2 • Public • Published

Resolve Locals Build Status

Resolve a component's local dependencies.

Some differences between the older component libs:

  • Handles the newer component specs
  • Only resolves the local components - dependencies, installs, and builds will be handled separately
  • Written in co generators
  • Some component.json validation and normalization, specifically for backwards compatibility
  • Easier debugging - returns component.jsons will resolved values, so you know what what is going on

API

var resolve = require('resolve-locals')

resolve(process.cwd(), {
  dev: true
})
.on('local')
.on('dependency')
.on('end')
.on('error')

resolve(root, [options])

root is the root path where the initial component.json is defaulting to process.cwd(). options are:

  • dev - include development dependencies

.end([done])

Returns all locals and dependencies as an object of the form:

{
  locals: [],
  dependencies: []
}

You may use a callback or a generator:

resolve().end(function (err, result) {

})

var result = yield resolve().end()

This is optional. You probably want to listen to events instead.

Event: local

Emitted every time a local component is resolved. The main component.json will be emitted last.

Each local will have additional properties:

  • filename - the absolute path of the component.json. Useful for resolving files, other locals, etc.
  • resolved - resolved information
    • locals - map of local name to the local's resolved component.json, ex. locals.boot = {"name": "boot", ...}
    • paths - the paths used to look up locals. Useful for debugging when using multiple paths.

Event: dependency

Emitted everytime a component needs a dependency. Emitted so that another resolver can handle these. Each dependency will have the following properties:

  • name - the name of the dependency, such as component/emitter
  • release - the version of the dependency, such as ~1.1.1 or master
  • remotes - array of remotes to use to retrieve this dependency. Note: this resolver does not make an opinion as to what remotes dependencies should use by default (ex. GitHub).
  • dependent - the component's resolved component.json

Event: error

If an error is emitted, there will be no more events.

Event: end

When everything has been resolved.

License

The MIT License (MIT)

Copyright (c) 2013 Jonathan Ong me@jongleberry.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i resolve-locals.js

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • jongleberry