Giter Site home page Giter Site logo

yeoman / update-notifier Goto Github PK

View Code? Open in Web Editor NEW
1.7K 21.0 129.0 205 KB

Update notifications for your CLI app

License: BSD 2-Clause "Simplified" License

JavaScript 100.00%
update-notifier update-chec updater notifications command-line-utility node-module npm-package

update-notifier's Introduction

update-notifier

Update notifications for your CLI app

Inform users of your package of updates in a non-intrusive way.

Contents

Install

npm install update-notifier

Usage

Simple

import updateNotifier from 'update-notifier';
import packageJson from './package.json' assert {type: 'json'};

updateNotifier({pkg: packageJson}).notify();

Comprehensive

import updateNotifier from 'update-notifier';
import packageJson from './package.json' assert {type: 'json'};

// Checks for available update and returns an instance
const notifier = updateNotifier({pkg: packageJson});

// Notify using the built-in convenience method
notifier.notify();

// `notifier.update` contains some useful info about the update
console.log(notifier.update);
/*
{
	latest: '1.0.1',
	current: '1.0.0',
	type: 'patch', // Possible values: latest, major, minor, patch, prerelease, build
	name: 'pageres'
}
*/

Options and custom message

const notifier = updateNotifier({
	pkg,
	updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week
});

if (notifier.update) {
	console.log(`Update available: ${notifier.update.latest}`);
}

How

Whenever 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. The update check is done in a unref'ed child process. This means that if you call process.exit, the check will still be performed in its own process.

The first time the user runs your app, it will check for an update, and even if an update is available, it will wait the specified updateCheckInterval before notifying the user. This is done to not be annoying to the user, but might surprise you as an implementer if you're testing whether it works. Check out example.js to quickly test out update-notifier and see how you can test that it works in your app.

API

notifier = updateNotifier(options)

Checks if there is an available update. Accepts options defined below. Returns an instance with an .update property if there is an available update, otherwise undefined.

options

Type: object

pkg

Type: object

name

Required
Type: string

version

Required
Type: string

updateCheckInterval

Type: number
Default: 1000 * 60 * 60 * 24 (1 day)

How often to check for updates.

shouldNotifyInNpmScript

Type: boolean
Default: false

Allows notification to be shown when running as an npm script.

distTag

Type: string
Default: 'latest'

Which dist-tag to use to find the latest version.

notifier.fetchInfo()

Check update information.

Returns an object with:

  • latest (string) - Latest version.
  • current (string) - Current version.
  • type (string) - Type of current update. Possible values: latest, major, minor, patch, prerelease, build.
  • name (string) - Package name.

notifier.notify(options?)

Convenience method to display a notification message. (See screenshot)

Only notifies if there is an update and the process is TTY.

options

Type: object

defer

Type: boolean
Default: true

Defer showing the notification to after the process has exited.

message

Type: string
Default: See above screenshot

Message that will be shown when an update is available.

Available placeholders:

  • {packageName} - Package name.
  • {currentVersion} - Current version.
  • {latestVersion} - Latest version.
  • {updateCommand} - Update command.
notifier.notify({message: 'Run `{updateCommand}` to update.'});

// Output:
// Run `npm install [email protected]` to update.
isGlobal

Type: boolean
Default: Auto-detect

Include the -g argument in the default message's npm i recommendation. You may want to change this if your CLI package can be installed as a dependency of another project, and don't want to recommend a global installation. This option is ignored if you supply your own message (see above).

boxenOptions

Type: object
Default: {padding: 1, margin: 1, textAlignment: 'center', borderColor: 'yellow', borderStyle: 'round'} (See screenshot)

Options object that will be passed to boxen.

User settings

Users 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].json. The path is available in notifier.config.path.

Users can also opt-out by setting the environment variable NO_UPDATE_NOTIFIER with any value or by using the --no-update-notifier flag on a per run basis.

The check is also skipped automatically:

  • in CI
  • in unit tests (when the NODE_ENV environment variable is test)

About

The 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.

Users

There are a bunch projects using it:

  • npm - Package manager for JavaScript
  • Yeoman - Modern workflows for modern webapps
  • AVA - Simple concurrent test runner
  • XO - JavaScript happiness style linter
  • Node GH - GitHub command line tool

And 2700+ more…

update-notifier's People

Contributors

addyosmani avatar develar avatar ecmarsh avatar ehmicky avatar fisker avatar fregante avatar hemanth avatar iambumblehead avatar jokeyrhyme avatar kevva avatar litomore avatar meain avatar mstuart avatar nexdrew avatar nikeee avatar nikhilkh avatar passy avatar renatoagds avatar rhettl avatar samccone avatar santi avatar satazor avatar sboudrias avatar simenb avatar sindresorhus avatar svnlto avatar targos avatar timdeschryver avatar willnode avatar wtgtybhertgeghgtwtg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

update-notifier's Issues

Custom update message is not working

As I see from commit history and outdated README there was an option for setting custom update message. Is there a possibility to bring it back to the opts object (09cba33)?
So, let's say, the message would be passed like that

notifier.notify({
  defer: false,
  message: customMessage
});

Patch release broke [email protected]

[email protected] supports [email protected] but the recent patch release of [email protected] breaks it.

> bower install


PROJECT/node_modules/bower/node_modules/update-notifier/node_modules/configstore/configstore.js:12
var tmpDir = path.join(os.tmpdir(), user);
                          ^
TypeError: Object #<Object> has no method 'tmpdir'
    at Object.<anonymous> (PROJECT/node_modules/bower/node_modules/update-notifier/node_modules/configstore/configstore.js:12:27)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (PROJECT/node_modules/bower/node_modules/update-notifier/lib/update-notifier.js:5:19)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)

While [email protected] updated its engine to require [email protected], npm is not respecting it for some reason. Can we release another patch which is 0.1.7 as 0.1.9 and release 0.1.8 as a minor (e.g. 0.2.0)?

Don't count deprecated versions as new versions

We are using update-notifier internally to force everyone to be on the latest version of a command line tool. Today someone pushed a broken build, and then promptly npm deprecated it.

It would be nice if deprecated versions simply didn't count as a new version.

Malformed .config/configstore/update-notifier-*.yml

Our jenkins user had a .config/configstore/update-notifier-bower.yml file that was malformed. The contents of the file was:

lastUpdateCheck: 1370806832784
1370791520799

Any attempt to run bower as the jenkins user terminated on the following line with no output or non-zero exit code:

 19 var notifier = updateNotifier({ packageName: pkg.name, packageVersion: pkg.version });

This is perhaps two issues: that the yml file was written malformed, and the handling of that error.

For the former, I suspect that two of our jenkins projects executed bower at the same time and the updates to the yml file collided. I haven't inspected the code but maybe an atomic rename would ensure consistency.

For the latter, it would be great if update-notifier could handle this error gracefully. In my case, deleting the file was sufficient to make bower work again. Alternatively an error message and exit error code would be helpful too.

Support for Non-NPM (git repo) installed tools

we have an internal (enterprise) github with private npm packages that we don't publish anywhere, so we have installs like: npm install -g git://github....

Would be great to have update support for cli tools installed this way :)

Cannot read property 'update' of null

Hi, I'm getting the following error randomly, sometimes it works.

/folder/stf/node_modules/update-notifier/node_modules/configstore/configstore.js:85
    return this.all[key];
                   ^
TypeError: Cannot read property 'update' of null
    at Object.Configstore.get (/folder/stf/node_modules/update-notifier/node_modules/configstore/configstore.js:85:17)
    at UpdateNotifier.check (/folder/stf/node_modules/update-notifier/index.js:42:28)
    at module.exports (/folder/stf/node_modules/update-notifier/index.js:118:17)
    at Object.<anonymous> (/folder/stf/lib/cli.js:18:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
FTL/cli:local 31169 [*] Child process had an error ExitError: Exit code "8"
    at ChildProcess.<anonymous> (/folder/stf/lib/util/procutil.js:49:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:797:12)

Allow customisation of the update instruction

I have a module that needs to be installed/updated with --unsafe-perm in order to allow it to hook into another CLI. I need the update instruction to include that.

Current:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Update available: 2.0.1 (current: 2.0.0) β”‚
β”‚ Run npm update -g tn to update.          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Wanted:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Update available: 2.0.1 (current: 2.0.0)      β”‚
β”‚ Run npm update -g tn --unsafe-perm to update. β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Proposed implementation:

updateNotifier({
  packageName: pkg.name,
  packageVersion: pkg.version,
  command: 'npm update -g tn --unsafe-perm'
}).notify();

Told me to update, but my version is already the latest one

Issuehunt badges

More at: raineorshine/npm-check-updates/issues/190


IssueHunt Summary

fregante fregante has been rewarded.

Backers (Total: $60.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Package from git

We have internal tool named "manage". It installs from our internal git repo.
So, notifier says, that version 1.0.0 (from npm https://www.npmjs.com/package/manage) bigger than our (0.9.7 from package.json). Can i use get repo instead global npm site?

Update notifier throws "spawn E2BIG" error

I am getting "spawn E2BIG" error when I am trying to use the updater. I am on Ubuntu 15.10 (x64).

This is how the notifier is used:

var pkg = require('../package.json');
var updateNotifier = require('update-notifier');

var notifier = updateNotifier({
pkg: pkg,
updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week
});

notifier.notify();

default to registryUrl from user's local npm config

Instead of

this.registryUrl = options.registryUrl || 'http://registry.npmjs.org/%s';

It would be helpful to default to the registry that npm(1) would use. This makes this feature helpful for those using alternate registries or private ones for their non-open source node modules.

I haven't looked into the best way to get that value.

The non-node way:

$ npm config get registry
https://registry.npmjs.org/

optional notify spacing

Because the two "\n", The distance between custom message and notify message is far.

Why it does not handle as an option like below?

updateNotifier.notify({spacing: false});

If accepted I'll improve code!

image

Heaviness

Want to use this for a cli, but it's already gotten heavy and this adds on quite a bit to install time.

Looking into it, latest-version => package-json => got => (10 dependencies)

So if we could avoid package-json this package would be lean and mean, as it should be.

Cannot read property 'latest' of undefined

TypeError: Cannot read property 'latest' of undefined
    at UpdateNotifier.<anonymous> (/Users/nexus/Public/igloo/node_modules/update-notifier/lib/update-notifier.js:90:36)
    at Request.self.callback (/Users/nexus/Public/igloo/node_modules/update-notifier/node_modules/request/request.js:129:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/Users/nexus/Public/igloo/node_modules/update-notifier/node_modules/request/request.js:873:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Users/nexus/Public/igloo/node_modules/update-notifier/node_modules/request/request.js:824:12)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:919:16
    at process._tickCallback (node.js:419:13)
^C%

publish new release

Thank you very much for this package. One little pbm: Updating the dep versions here fixes 401 (Unauthorized) for private scoped packages. But latest version 0.5.0 on npm is not updated with fixes. Can we please publish latest version?

Update configstore dependency

The current used version uses configstore ^1.0.0 wich depends on graceful-fs<4. graceful-fs<4 is deprecated as it uses node APIs that will soon be unavailable.
The update-notifier should upgrade to configstore ^2.0.0 to avoid incompability with newer node versions, if possible.

Update configstore to 0.2.2

Occasionally, this issue comes up in our builds:

Uncaught TypeError: Cannot read property 'update' of null
      at Object.Configstore.get (/home/travis/build/paypal/generator-kraken/node_modules/update-notifier/node_modules/configstore/configstore.js:83:17)
      at UpdateNotifier.check (/home/travis/build/paypal/generator-kraken/node_modules/update-notifier/lib/update-notifier.js:51:28)
      at module.exports (/home/travis/build/paypal/generator-kraken/node_modules/update-notifier/lib/update-notifier.js:142:17)

I re-ran our build (w/ same code) and it passed. Maybe a race condition somewhere along the way?
Working build
Broken build

It seems to have been fixed this commit in configstore 0.2.2

Can you update configstore to 0.2.2 to eliminate chances of this occasional error? I'll create a PR

0.1.10 drops node 0.8 support?

I've had issues files against nodemon because ppl can't install the npm Presley's anymore and it's due to the configstore module used here no longer supporting node 0.8.

Here's a failing build for reference: https://travis-ci.org/remy/nodemon/jobs/28883322

Can you confirm that this is an intentional drop of support. I'd rather keep using this module, but given that I'm using it in a utility I'll likely have to reinvent the wheel :(

Add a method for directly checking for an update

Issuehunt badges

Having the callback specified as a field in the options object makes this library incompatible with e.g. pify and I think all other promisify-libraries as well. It's also very uncommon in the Node.js community where the callback is usually given as the last parameter.

Would it be possible to update to a form where the callback is given as a second parameter? This could probably be done in a backwards compatible way as well. Possibly printing deprecation warning and then dropping it in the next major version.

Any thoughts?


IssueHunt Summary

litomore litomore has been rewarded.

Backers (Total: $40.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Our app using update-notifier is crashing for a lot of our users

Original issue: tessel/t2-cli#714

We have quite a few users that are getting crashes because they don't have permissions to write to the config file used. Unfortunately, I'm not sure exactly why this happens, and I'm not even sure how this should be handled, but I thought it was a good idea to open this ticket to get some thoughts.

On the one hand, the behaviour could be considered correct. But on the other hand, it might be a good idea to fail gracefully since this is more of an advisory tool.

I've confirmed that wrapping the call to update notifier in a try/catch correctly catches the problem, so that is one way of dealing with it from our side.

Allow update message to be customized via notify(opts) method

A similar idea in #43 was dismissed as "useless", but now that the .notify() method is non-trivial, why not allow things like message parts, chalk styles, and boxen settings to be customized via opts? This would make the .notify() method more consumer-friendly and reusable.

Consider that if someone wants to provide the same functionality but with a slight customization, they currently have to duplicate/reproduce the following:

  • is-npm dependency
  • boxen dependency
  • chalk dependency
  • check for !process.stdout.isTTY || isNpm || !notifier.update
  • message parts/concatenation
  • chalk styles
  • boxen settings/style
  • check for deferral and process exit listener

That's kind of a lot.

I think it would be nice to support the following:

  • opts.updateCommand: string like 'sudo npm i %s -g --ignore-scripts'
  • opts.boxenOptions: object passed directly to boxen

But we could get even more granular than that:

  • opts.updateAvailableMessage: string like 'Update available %s β†’ %s'
  • opts.runMessage: string like 'Run %s to update'
  • opts.currentVersionStyle: string like 'dim' or function like chalk.dim
  • opts.latestVersionStyle: string like 'green' or function like chalk.green
  • opts.updateCommandStyle: string like 'cyan' or function like chalk.cyan
  • opts.padding: integer passed to boxen
  • opts.margin: integer passed to boxen
  • opts.borderColor: string passed to boxen
  • opts.borderStyle: string passed to boxen

A bonus for supporting message/text customization is that folks can then support i18n if they want, but still get the benefit of the other logic.

Thoughts?

How to confirm it's working?

I'm using update-notifier on ESBox.

I added update-notifier to [email protected], and now [email protected] is out. So I thought I'd test if update-notifier is working by doing npm install -g [email protected] then running it. I've run esbox --help several times (including waiting a few hours in between runs) but I never get the update notification. I've also tried deleting ~/.config/configstore/update-notifier-esbox.json and I can see the file gets re-created when I run esbox --help again. But on subsequent runs, it still never shows the message.

Am I doing something wrong?

opts.defer doesn't defer on true

when opts.defer is checked, it is checked against undefined only. index.js#L123

if (opts.defer === undefined) {
    process.on('exit', function () {
            console.error(message);
    });

    process.on('SIGINT', function () {
        console.error('\n' + message);
    });
} else {
    console.error(message);
}

Update information in config is deleted whether user updated app or not

In index.js, lines 35-37 SHA: 3b83163

if (this.update) {
    this.config.del('update');
}

These lines are causing deletion of update information whether user updated app or not. It can be misleading, resulting in update information not being shown every time it's available, especially for short running apps.

As a solution I suggest moving it from index.js to check.js where update information will be removed only if there's no update available. Something like this:

// Delete update information if current and latest version are equal
if (update.current && update.latest && update.current === update.latest) {
    updateNotifier.config.del('update');
}

just before process.exit().

Option to make it more intrusive?

Hi! I recently had an amusing issue in which someone who uses my team's cli app didn't realize that updating was necessary to solve their problem. At first, they didn't even see the update notifier output. Then, after they saw it, it didn't occur to them that updating was important:

It's just like all those annoying requests to update Flash or Java that don't actually impact my usage of those tools in any way. And the message didn't look ominous or like something that required immediate attention.

To make this stand out to people more, I'm considering different options, like a giant ASCII-art pigeon, or the lyrics of Too Many Cooks printed out line-by-line with a sleep between each one. Would you have any interest in this? (It would be opt-in for consumers of this module, of course.) I could submit it as a PR, but it would also be easy to just implement it in my own project.

This is the pigeon I would use, in case it makes a difference:


     .-''-.
    / ,    \
 .-'`(o)    ;
'-==.       |
      `._...-;-.
      )--"""   `-.
     /   .        `-.
    /   /      `.    `-.
    |   \    ;   \      `-._________
    |    \    `.`.;          -------`.
     \    `-.   \\\\          `---...|
      `.     `-. ```\.--'._   `---...|
        `-.....7`-.))\     `-._`-.. /
          `._\ /   `-`         `-.,'
            / /
           /=(_
        -./--' `
      ,^-(_
      ,--' `

Request: Support Private Scoped Modules

Referencing sindresorhus/latest-version#3, it would be great for this module to support private modules. This probably requires using the npm module rather than the HTTPS endpoint in latest-version. Assuming that won't happen, it may be a good option to allow consumers of update-notifier to specify which 'latest' module they'd like to use. Users in my situation could pass a reference to the latest module, which uses npm and the user's .npmrc with the auth token to access private modules.

Notifies about prereleases

If you push a prerelease version of your library, update-notifier will inform users that they should upgrade (which they should not, honestly), and provide them with a faulty command for the upgrade which will do nothing and stay at the current version.

I'd be happy to take a stab at fixing this through a PR, just want to make sure that this is good with the maintainer(s) of this library before I start.

notify() options in README.md has typos

I know this is small, but it cost me a few minutes to figure out and is easy to change...

In readme.md:

  • rename the notify() method's options.name property to options.packageName
  • rename the notify() method's options.version property to options.packageVersion
  • Clarify that if pkg is passed, it will ignore try to use pkg.name and pkg.version(if they exist) instead of the above properties

FWIW, I came across this issue while developing generator-confit, which uses semantic versioning, so the version in package.json was set to 0.0.0-semantically-released. I needed to read the source code to see what was going on.

Great package btw! πŸ‘

Add option to tweak the timeout

I don't know what's the timeout of the update-notifier or if it even has one. But it would be nice to have an option to tweak the maximum time that update-notifier would check for a newer version.

Race condition with configstore

From typings/typings#80 (comment).

I'm not the original author, see linked issue, but it appears some sort of race condition might be occurring when checking for updates in multiple processes that are being spawned. If this is the case, a solution might be to set the config store before running the check, then having subsequent stores use the latest config to check if a different check script is already currently executing. This would avoid having multiple updates executing at once, though I can't tell if it'd solve the core issue.

TypeError: Cannot read property 'optOut' of null

I am getting the following exception when using 'nodemon' which uses 'update-notifier':

exception in nodemon killing node
TypeError: Cannot read property 'optOut' of null
at Object.Configstore.get (/usr/local/pkgs/node-v0.10.25-linux-x64/lib/node_modules/nodemon/node_modules/update-notifier/node_modules/configstore/configstore.js:83:17)
at UpdateNotifier.check (/usr/local/pkgs/node-v0.10.25-linux-x64/lib/node_modules/nodemon/node_modules/update-notifier/lib/update-notifier.js:47:18)
at module.exports (/usr/local/pkgs/node-v0.10.25-linux-x64/lib/node_modules/nodemon/node_modules/update-notifier/lib/update-notifier.js:142:17)
at Object. (/usr/local/pkgs/node-v0.10.25-linux-x64/lib/node_modules/nodemon/bin/nodemon.js:7:16)
at Module.compile (module.js:456:26)
at Object.Module.extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)

After more testing, I am able to reproduce this error. It is happening on an AWS EC2 micro instance, when I try to fire up 5 different node processes simultaneously from a bash script. Something like:

cd scriptdir1 && nodemon script1 > /var/log/script1.log 2>&1 &
cd scriptdir2 && nodemon script2 > /var/log/script2.log 2>&1 &
cd scriptdir3 && nodemon script3 > /var/log/script3.log 2>&1 &
cd scriptdir4 && nodemon script4 > /var/log/script4.log 2>&1 &
cd scriptdir5 && nodemon script5 > /var/log/script5.log 2>&1 &

Usually, 2 out of the 5 log files will simply contain the exception shown in previous comment.

If I tinker a little in order to space out the firing up of the nodemon processes using 'sleep' like this:

sleep .0 && cd scriptdir1 && nodemon script1 > /var/log/script1.log 2>&1 &
sleep .1 && cd scriptdir2 && nodemon script2 > /var/log/script2.log 2>&1 &
sleep .2 && cd scriptdir3 && nodemon script3 > /var/log/script3.log 2>&1 &
sleep .3 && cd scriptdir4 && nodemon script4 > /var/log/script4.log 2>&1 &
sleep .4 && cd scriptdir5 && nodemon script5 > /var/log/script5.log 2>&1 &

Then I never get the error.

Note: I have also posted this issue with 'nodemon'.

Investigate use of child_process.fork

Might prove useful to separate the .checkNpm() method with the rest so it doesn't delay exit of short lived modules. Though kind of edge case, since update check is max once per day and is only takes about a second.

When run right after npm install, a wrong version is displayed

Issuehunt badges

update-notifier is used in https://github.com/greenkeeperio/greenkeeper, with which I run into the following error: greenkeeperio/greenkeeper#33 (comment)

Can this be resolved somehow?


IssueHunt Summary

fregante fregante has been rewarded.

Backers (Total: $60.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Crazypants idea: change notes

If out of date, check for a changelog.md (or maybe changelog.tldr.md; configurable). Then print out all the goodies that the user is missing, 'cause we want to tempt them!

Globally opt-out

I'd like the option to globally opt-out rather than opting out of every app individually. I was thinking that an environment variable check would be the way to go. Thoughts?

If no internet, lastUpdateCheck should not get updated

I tested this with the internet down, so that the check wouldn't cause any problems to my script (which it doesn't - good stuff), but the yaml file's lastUpdateCheck does get updated, which could cause it to skip a release even though the check was made whilst there was no internet connection.

Improve performance by loading dependencies only when needed.

Some of the node modules that index.js depends on do not need to be loaded, unless a later version of an npm module is found. Delay loading them provides better startup performance by pay-for-play. Here's the simple test that I performed on warm-startup and it improve the node module load time by 50% for update-notifier and it's children.

I will shortly submit a PR with my change.

--- a/before.txt
+++ b/after.txt
@@ -1,36 +1,18 @@
->> Module load abbrev parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 2
-> Module load nopt parent: . : 7
+> Module load nopt parent: . : 3
 > Module load underscore parent: . : 5
->> Module load child_process parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 2
->>>> Module load ./polyfills.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 2
->>> Module load graceful-fs parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 7
->>> Module load osenv parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 3
+>> Module load child_process parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 3
+>>>>> Module load ./fs.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/node_modules/graceful-fs/graceful-fs.js : 2
+>>>> Module load ./polyfills.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 3
+>>> Module load graceful-fs parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 9
+>>> Module load osenv parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 4
+>>> Module load object-assign parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 2
 >>>>> Module load crypto parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/node_modules/uuid/uuid.js : 4
 >>>> Module load ./rng parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 5
 >>> Module load uuid parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 7
 >>> Module load xdg-basedir parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 2
->>>> Module load slide parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 2
->>> Module load write-file-atomic parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 4
->> Module load configstore parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 28
->> Module load chalk parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 5
->>> Module load semver parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 2
->> Module load semver-diff parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 3
->>>>> Module load http parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 3
->>>>> Module load https parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 3
->>>>>> Module load stream parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/index.js : 2
->>>>>> Module load ./lib/_stream_readable.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/index.js : 5
->>>>>> Module load ./lib/_stream_writable.js parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/index.js : 2
->>>>> Module load readable-stream parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 11
->>>>> Module load url-parse-lax parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 2
->>>>>> Module load ./vendor/parse parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/index.js : 2
->>>>> Module load parse-json parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 3
->>>>> Module load ./package.json parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 2
->>>> Module load got parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/index.js : 37
->>>>> Module load ./lib/utils parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/index.js : 2
->>>> Module load rc parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/latest-version/index.js : 4
->>> Module load package-json parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 42
->> Module load latest-version parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 43
->>> Module load string-width parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 4
->> Module load boxen parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 9
-> Module load update-notifier parent: . : 92
+>>>> Module load slide parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/node_modules/configstore/index.js : 3
+>>> Module load write-file-atomic parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 6
+>>> Module load dot-prop parent: /Users/nikhil/Developer/cordova/cordova-cli/node_modules/update-notifier/index.js : 3
+>> Module load configstore parent: /Users/nikhil/Developer/cordova/cordova-cli/src/cli.js : 35
+> Module load update-notifier parent: . : 40

Usage without callback never sets notifier.update

When using update-notifier without callback the notifier.update will never set with the update information:

var updateNotifier = require('update-notifier');
var notifier = updateNotifier({
    packageName: 'update-notifier-tester',
    packageVersion: '0.0.2'
});
if (notifier.update) {
    // never happens
}

Same setting with a callback works just fine (the callback gets the update object).

The config file in my profile is created when I use without callback, but it only contains this:

optOut: false
lastUpdateCheck: 1386985496657

I'm on windows using node v0.10.22.

Formatting issue

Hi,
I'm using codio as my editor (it's free and awesome by the way)
The box does not close well on the right as you can see here:
codio_-_generator-angular-famous-ionic

Outside of codio (using my laptop local command line) everything works fine:

1__thaiat_avis-macbook-pro_____zsh_

This is really non blocking, just for your info

Passing the content of package.json as a command line argument could cause problems

In the check method we pass the options object as a command line argument to check.js (see relevant line here). This means we pass the entire content of package.json as a command line argument (at least if the user followed the examples and didn't pass a custom pkg object). This is a potential problem, since certain platforms have a limit to the maximum length of the command line string (at least Windows does). So it can cause issues with really big package.json files. I think it would be better, if we update options.pkg (in the UpdateNotifier constructor) to contain just the relevant keys (name and version), so this will never become an issue.

Notifier throwing exception when checking for update: 'update' of null

I don't have much useful information, but I'm using update-notifier as documented in http://github.com/remy/nodemon and a user is reporting this exception.

Detailed dump here: remy/nodemon#241 (scroll down where it starts with "Also saw this"). For now I'm going to have to try/catch this call, but it would be good to get to the bottom of the issue - but, at time of writing, I can't personally replicate this. Not useful, I know!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.