duo-package

package downloader for duo

Usage no npm install needed!

<script type="module">
  import duoPackage from 'https://cdn.skypack.dev/duo-package';
</script>

README

Duo Package

NPM version build status

Duo's GitHub package installer.

Features

  • github-style urls
  • semver support
  • flexible api
  • checks local before fetching remote
  • private repo support

Example

var pkg = new Package('matthewmueller/cheerio', '0.13.x')
  .token(process.env.token)
  .directory('components');

pkg.fetch(function(err) {
  if (err) throw err;
  console.log('fetched: %s', pkg.slug());
})

API

Package(name, ref)

initialize a new Package with name and ref, where name is a github-style url and ref is either a tag or a branch. ref supports semver versioning.

Examples:

Package('matthewmueller/uid', '*');
Package('matthewmueller/uid', 'master');
Package('matthewmueller/uid', 'some/feature');
Package('matthewmueller/uid', '~0.1.0');

Package#token(token)

authenticate with github. you can create a new token here: https://github.com/settings/tokens/new.

Package#directory(dir)

set a directory to install the package in.

Package#cache(cache)

cache instance created by duo.

Package.path([path])

Get the path of the fetched package. optionally add a relative path.

Package.useragent([ua])

Get or set the user agent header duo-package uses to make requests. defaults to duo-package.

Package.resolve([fn])

Resolve a package's version

Package.fetch([fn])

fetch the package. returns a generator that can be yielded in a generator function or wrapped in co.

yield pkg.fetch()

Package.slug()

Return the full package name (ie. component/emitter@1.0.0)

Authors

License

The MIT License

Copyright © 2014

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.