On Aug 24, 2015, at 1:49 AM, Kevin Chavez wrote:

> I'm writing a cli to run on node. I'm going to distribute it using npm. I 
> really like Chrome/Firefox's model of automatic updates.
> 
> Would it be a bad idea to simply call the following on startup, or right 
> before the process ends?
> 
> require('child_process').exec('npm update -g package-name');
> 
> I honestly don't see why it wouldn't, assuming all users install through npm.
> 
> Anyway, don't want to mess this one up, but it's hard to test before 
> deploying. Thought I'd ask the experts.

You're talking about updating your own module when someone runs a program 
installed by your module? That's probably not a good idea. Auto-updating is 
probably not what users expect when installing software with npm.

Also, if your module depends on other modules, this might result in other 
modules being updated. It's possible the developers of those other modules have 
released and update that is incompatible with your code, which would break your 
code.

Finally, it's going to get tricky to update your own module. Imagine someone 
runs your program "foo", and as its first step, it tries to update itself. Then 
what should it do? Should it exit and re-run the new version of itself? You'll 
have to deal with passing along all the command line arguments, environment 
variables, possibly even redirected file handles like stdin, stdout, stderr.

Firefox and Chrome have different autoupdate models. Firefox checks for updates 
when you run it, while Chrome has a separate process that periodically checks 
for updates. Periodically checking for updates is less problematic for users, 
and avoids some of the above programming problems as well.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/EEE53161-EF97-4B0E-8A32-945520DAF67B%40ryandesign.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to