Skip to content

Commit

Permalink
Merge pull request #244 from domcleal/latest-ignore-npm-cache
Browse files Browse the repository at this point in the history
Ignore npm cache lines when calling 'npm view' for latest version
  • Loading branch information
jyaworski authored Aug 31, 2016
2 parents f324048 + 1b3f0c0 commit 01470e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/puppet/provider/package/npm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def query
end

def latest
npm('view', resource[:name], 'version').strip
npm('view', resource[:name], 'version').lines.reject { |l| l.start_with?('npm') }.join("\n").strip
end

def update
Expand Down
9 changes: 8 additions & 1 deletion spec/unit/puppet/provider/package/npm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def self.it_should_respond_to(*actions)
end

describe 'when npm packages are installed globally' do
before :each do
before do
provider.class.instance_variable_set(:@npmlist, nil)
end

Expand All @@ -67,4 +67,11 @@ def self.it_should_respond_to(*actions)
expect(provider.class.instances).to eq([])
end
end

describe '#latest' do
it 'filters npm registry logging' do
provider.expects(:npm).with('view', 'express', 'version').returns("npm http GET https://registry.npmjs.org/express\nnpm http 200 https://registry.npmjs.org/express\n2.0.0")
expect(provider.latest).to eq('2.0.0')
end
end
end

0 comments on commit 01470e2

Please sign in to comment.