Skip to content

everyside/resin-image-manager

 
 

Repository files navigation

resin-image-manager

npm version dependencies Build Status Build status

Manage device base operating systems resources with caching support.

Role

The intention of this module is to provide low level access to how a Resin.io device image is downloaded, cached and evaluated for freshness.

THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY.

Installation

Install resin-image-manager by running:

$ npm install --save resin-image-manager

Documentation

manager.get(slug) ⇒ Promise.<ReadStream>

This function saves a copy of the downloaded image in the cache directory setting specified in resin-settings-client.

Kind: static method of manager
Summary: Get a device operating system image
Returns: Promise.<ReadStream> - image readable stream
Access: public

Param Type Description
slug String device type slug

Example

manager.get('raspberry-pi').then (stream) ->
	stream.pipe(fs.createWriteStream('foo/bar.img'))

manager.cleanCache() ⇒ Promise

Useful to manually force an image to be re-downloaded.

Kind: static method of manager
Summary: Clean the saved images cache
Access: public
Example

manager.cleanCache()

manager.pipeTemporal(stream) ⇒ Promise.<String>

If the image is a zip directory, it's uncompressed to a temporal location.

Make you delete the temporal file after you're done with it.

Kind: static method of manager
Summary: Pipe image stream to a temporal location
Returns: Promise.<String> - temporal location
Access: public

Param Type Description
stream Stream image stream

Example

manager.get('raspberry-pi').then (stream) ->
	manager.pipeTemporal(stream)
.then (temporalPath) ->
	console.log("The image was piped to #{temporalPath}")

Support

If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.

Tests

Run the test suite by doing:

$ gulp test

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning:

$ gulp lint

License

The project is licensed under the MIT license.

About

Manage device base operating systems resources with caching support.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages