# selfupdate

> Selfupdate your global NPM package

Latest version **1.1.0** (published 2015-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install selfupdate
pnpm add selfupdate
yarn add selfupdate
bun add selfupdate
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2015-05-13 |
| First published | 2015-05-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | Juan Cruz Viotti |
| Maintainers | jviotti |
| Keywords | selfupdate, update, autoupdate, npm |

## Links

- npm: https://www.npmjs.com/package/selfupdate
- Repository: https://github.com/resin-io/selfupdate
- Issues: https://github.com/resin-io/selfupdate/issues
- npm.io page: https://npm.io/package/selfupdate

## Dependencies (4)

- [npm](https://npm.io/package/npm.md) ^2.9.1
- [async](https://npm.io/package/async.md) ^0.9.0
- [president](https://npm.io/package/president.md) ^1.0.0
- [lodash-contrib](https://npm.io/package/lodash-contrib.md) ^241.4.14

## Recent versions

- 1.1.0 (latest) — 2015-05-13
- 1.0.0 — 2015-05-13

## README

selfupdate
----------

[![npm version](https://badge.fury.io/js/selfupdate.svg)](http://badge.fury.io/js/selfupdate)
[![dependencies](https://david-dm.org/jviotti/selfupdate.png)](https://david-dm.org/jviotti/selfupdate.png)
[![Build Status](https://travis-ci.org/jviotti/selfupdate.svg?branch=master)](https://travis-ci.org/jviotti/selfupdate)

Selfupdate your global NPM package.

Installation
------------

Install `selfupdate` by running:

```sh
$ npm install --save selfupdate
```

Documentation
-------------

### selfupdate.update(Object packageJSON, Function callback)

Update a globally installed NPM package.

If the installation fails with a permission related error, the module will attempt to elevate privileges automatically.

The function requires the `package.json`, which you can require like:

```javascript
var packageJSON = require('./package.json');
```

The callback gets passed two arguments: `(error, version)`, where `version` is the new version of the package after the update took place.

Example:

```javascript
var selfupdate = require('selfupdate');
var packageJSON = require('./package.json');

selfupdate.update(packageJSON, function(error, version) {
		if(error) throw error;
		console.log('The package was updated to version: ' + version);
});
```

### selfupdate.isUpdated(Object packageJSON, Function callback)

Check if a global package is in the latest version.

The function requires the `package.json`, which you can require like:

```javascript
var packageJSON = require('./package.json');
```

The callback gets passed two arguments: `(error, isUpdated)`, where `isUpdated` is a `Boolean` that determines if the package is up to date.

Example:

```javascript
var selfupdate = require('selfupdate');
var packageJSON = require('./package.json');

selfupdate.isUpdated(packageJSON, function(error, isUpdated) {
		if(error) throw error;
		console.log('Is the package up to date? ' + isUpdated);
});
```

Tests
-----

Run the test suite by doing:

```sh
$ gulp test
```

Contribute
----------

- Issue Tracker: [github.com/jviotti/selfupdate/issues](https://github.com/jviotti/selfupdate/issues)
- Source Code: [github.com/jviotti/selfupdate](https://github.com/jviotti/selfupdate)

Before submitting a PR, please make sure that you include tests, and that [coffeelint](http://www.coffeelint.org/) runs without any warning:

```sh
$ gulp lint
```

Support
-------

If you're having any problem, please [raise an issue](https://github.com/jviotti/selfupdate/issues/new) on GitHub.

ChangeLog
---------

### v1.1.0

- [feature] Expose selfupdate.isUpdated()

License
-------

The project is licensed under the MIT license.

---
_Source: https://npm.io/package/selfupdate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
