voxpupuli / puppet-nodejs

Puppet module to install nodejs and global npm packages
https://forge.puppet.com/puppet/nodejs
Apache License 2.0
113 stars 247 forks source link

Ignore npm cache lines when calling 'npm view' for latest version #244

Closed domcleal closed 8 years ago

domcleal commented 8 years ago

When the npm cache has expired or is empty, npm (version 1.3.6 at least) outputs requests it's making to stderr which are interpreted as a version number from the npm view command.

If using ensure=latest, this causes the package to be reinstalled every time the cache expires:

Debug: Executing: '/bin/npm view phantomjs version'
Debug: /Package[phantomjs]/ensure: phantomjs "2.1.7" is installed, latest is "npm http GET https://registry.npmjs.org/phantomjs\nnpm http 200 https://registry.npmjs.org/phantomjs\n2.1.7"
Debug: Executing: '/bin/npm install --global phantomjs'
Debug: /Package[phantomjs]/ensure: phantomjs "2.1.7" is installed, latest is "npm http GET https://registry.npmjs.org/phantomjs\nnpm http 200 https://registry.npmjs.org/phantomjs\n2.1.7"
Notice: /Package[phantomjs]/ensure: ensure changed '2.1.7' to 'npm http GET https://registry.npmjs.org/phantomjs
npm http 200 https://registry.npmjs.org/phantomjs
2.1.7'

The npm logging lines are now filtered out similarly to the npm list command.

juniorsysadmin commented 8 years ago

:+1: For non-global npm installs under npm.pp we use execs and I believe always re-install if ensure is set to latest. Not sure if we can do a similar thing there.