1.0.0 • Published 8 years ago

etcher-latest-version v1.0.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
8 years ago

etcher-latest-version

Utility to determine which is the latest published Etcher version

npm version dependencies Build Status

Installation

Install etcher-latest-version by running:

$ npm install --save etcher-latest-version

Documentation

module.exports(request, callback) ⏏

In order to make this function easily usable in both NodeJS and the browser, we decouple the latest version finder logic from the function that performs the HTTP GET request to the bucket URL.

You should pass a request function that takes two parameters: the url and a callback, and should call the latter with result of making an HTTP GET request to the passed URL.

For example, if you're using Angular, the request function will look something like this:

const request = (url, callback) => {
  $http.get(url).then((response) => {
    return callback(null, response.data);
  }).catch((error) => {
    return callback(error);
  });
};

Kind: Exported function
Summary: Get Etcher latest version
Access: public

ParamTypeDescription
requestfunctionHTTP GET request function
callbackfunctioncallback (error, latestVersion)

Example

const request = require('request');
const etcherLatestVersion = require('etcher-latest-version');

etcherLatestVersion((url, callback) => {
  request(url, function(error, response, body) {
    return callback(error, body);
  });
}, (error, latestVersion) => {
  if (error) {
    throw error;
  }

  console.log(`The latest version is: ${latestVersion}`);
});

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:

$ npm test

Contribute

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

$ npm run lint

License

The project is licensed under the Apache 2.0 license.