From 40319435eea7cbdd74057a05540c727b597256cd Mon Sep 17 00:00:00 2001 From: Zara Zaimeche Date: Mon, 8 Jun 2015 17:54:09 +0100 Subject: Fix: honour version flag in npm.to_lorry extension This fixes a version bug in npm.to_lorry that meant the most recent db entry was used for repo location, regardless of the version specified. The npm registry is a database of all versions of all packages, listing names, source locations, etc. There was a fun bug in npm.to_lorry that meant that the import tool would try access the repo listed in the database entry for the latest version of the package, rather than for the version specified. This meant that if version 1.0.1 of a package had the right url listed, but something was wrong with the url listed for version 1.4.6, the tool would error out, even if version 1.0.1 was requested. Change-Id: If40c8b4c85f5e27fee07ee88daa1e5d2d347944f --- baserockimport/exts/npm.to_lorry | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/baserockimport/exts/npm.to_lorry b/baserockimport/exts/npm.to_lorry index 65d8712..ab66f44 100755 --- a/baserockimport/exts/npm.to_lorry +++ b/baserockimport/exts/npm.to_lorry @@ -25,11 +25,18 @@ npm.load(function(er, npm) { throw ("Usage: ./npm.to_lorry PACKAGENAME [VERSION]"); } + if (process.argv.length === 4) + packageVersion = process.argv[3]; + else + packageVersion = 'latest'; + packageName = process.argv[2]; + var package = packageName +'@' + packageVersion; + if (er) throw er; - npm.commands.view([packageName], "silent", getRepo); + npm.commands.view([package], "silent", getRepo); function getRepo(er, packageInfo){ if (er) throw er; -- cgit v1.2.1