{ "name": "update-notifier", "version": "0.3.2", "description": "Update notifications for your CLI app", "license": "BSD", "repository": { "type": "git", "url": "git+https://github.com/yeoman/update-notifier.git" }, "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "http://sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha --timeout 20000" }, "files": [ "index.js", "check.js" ], "keywords": [ "npm", "update", "updater", "notify", "notifier", "check", "checker", "cli", "module", "package", "version" ], "dependencies": { "chalk": "^1.0.0", "configstore": "^0.3.1", "is-npm": "^1.0.0", "latest-version": "^1.0.0", "semver-diff": "^2.0.0", "string-length": "^1.0.0" }, "devDependencies": { "mocha": "*" }, "readme": "# update-notifier [![Build Status](https://travis-ci.org/yeoman/update-notifier.svg?branch=master)](https://travis-ci.org/yeoman/update-notifier)\n\n> Update notifications for your CLI app\n\n![](screenshot.png)\n\nInform users of your package of updates in a non-intrusive way.\n\n#### Table of Contents\n\n- [Examples](#examples)\n- [How](#how)\n- [API](#api)\n- [About](#about)\n\n\n## Examples\n\n### Simple example\n\n```js\nvar updateNotifier = require('update-notifier');\nvar pkg = require('./package.json');\n\nupdateNotifier({pkg: pkg}).notify();\n```\n\n### Comprehensive example\n\n```js\nvar updateNotifier = require('update-notifier');\nvar pkg = require('./package.json');\n\n// Checks for available update and returns an instance\nvar notifier = updateNotifier({pkg: pkg});\n\n// Notify using the built-in convenience method\nnotifier.notify();\n\n// `notifier.update` contains some useful info about the update\nconsole.log(notifier.update);\n/*\n{\n\tlatest: '1.0.1',\n\tcurrent: '1.0.0',\n\ttype: 'patch', // possible values: latest, major, minor, patch, prerelease, build\n\tname: 'pageres'\n}\n*/\n```\n\n### Example with settings and custom message\n\n```js\nvar notifier = updateNotifier({\n\tpkg: pkg,\n\tupdateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week\n});\n\nconsole.log('Update available: ' + notifier.update.latest);\n```\n\n\n## How\n\nWhenever you initiate the update notifier and it's not within the interval threshold, it will asynchronously check with npm in the background for available updates, then persist the result. The next time the notifier is initiated the result will be loaded into the `.update` property. This prevents any impact on your package startup performance.\nThe check process is done in a unref'ed [child process](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). This means that if you call `process.exit`, the check will still be performed in its own process.\n\n\n## API\n\n### updateNotifier(options)\n\nChecks if there is an available update. Accepts settings defined below. Returns an object with update info if there is an available update, otherwise `undefined`.\n\n### options\n\n#### pkg\n\nType: `object`\n\n##### name\n\n*Required* \nType: `string`\n\n##### version\n\n*Required* \nType: `string`\n\n#### updateCheckInterval\n\nType: `number` \nDefault: `1000 * 60 * 60 * 24` (1 day)\n\nHow often to check for updates.\n\n#### callback(error, update)\n\nType: `function` \n\nPassing a callback here will make it check for an update directly and report right away. Not recommended as you won't get the benefits explained in [`How`](#how).\n\n`update` is equal to `notifier.update`\n\n\n### updateNotifier.notify([options])\n\nConvenience method to display a notification message *(see screenshot)*.\n\nOnly notifies if there is an update and the process is [TTY](http://nodejs.org/api/tty.html).\n\n#### options.defer\n\nType: `boolean` \nDefault: `true`\n\nDefer showing the notication to after the process has exited.\n\n\n### User settings\n\nUsers of your module have the ability to opt-out of the update notifier by changing the `optOut` property to `true` in `~/.config/configstore/update-notifier-[your-module-name].yml`. The path is available in `notifier.config.path`.\n\nUsers can also opt-out by [setting the environment variable](https://github.com/sindresorhus/guides/blob/master/set-environment-variables.md) `NO_UPDATE_NOTIFIER` with any value.\n\nYou could also let the user opt-out on a per run basis:\n\n```js\nif (process.argv.indexOf('--no-update-notifier') === -1) {\n\t// run updateNotifier()\n}\n```\n\n\n## About\n\nThe idea for this module came from the desire to apply the browser update strategy to CLI tools, where everyone is always on the latest version. We first tried automatic updating, which we discovered wasn't popular. This is the second iteration of that idea, but limited to just update notifications.\n\nThere are a bunch projects using it:\n\n- [Yeoman](http://yeoman.io) - modern workflows for modern webapps\n\n- [Bower](http://bower.io) - a package manager for the web\n\n- [Pageres](https://github.com/sindresorhus/pageres) - responsive website screenshots\n\n- [Node GH](http://nodegh.io) - GitHub command line tool\n\n- [Hoodie CLI](http://hood.ie) - Hoodie command line tool\n\n- [Roots](http://roots.cx) - a toolkit for advanced front-end development\n\n[And 100+ more...](https://www.npmjs.org/browse/depended/update-notifier)\n\n\n## License\n\n[BSD license](http://opensource.org/licenses/bsd-license.php) and copyright Google\n", "readmeFilename": "readme.md", "bugs": { "url": "https://github.com/yeoman/update-notifier/issues" }, "homepage": "https://github.com/yeoman/update-notifier#readme", "_id": "update-notifier@0.3.2", "_shasum": "22a8735baadef3320e2db928f693da898dc87777", "_resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-0.3.2.tgz", "_from": "update-notifier@>=0.3.0 <0.4.0" }