]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
fetch2/npm: handle alternative dependency syntax
authorPaul Eggleton <paul.eggleton@linux.intel.com>
Mon, 7 Mar 2016 04:27:36 +0000 (17:27 +1300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 7 Mar 2016 17:19:40 +0000 (17:19 +0000)
npm allows you to specify a dependency as a Github username+path, or
omit the version entirely. You can hit these if you don't use a
shrinkwrap file, with the result that the code later fails due to the
output of "npm view" being empty; so handle this lazily by just ignoring
this part of the dependency if it's not really a version.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/fetch2/npm.py

index 59312f4f0136c6ceb56c890add5098c4fbdb6599..761c2e0e73cd14b3979b9f1113f5d43bfc7b83d9 100644 (file)
@@ -144,13 +144,15 @@ class Npm(FetchMethod):
 
     def _getdependencies(self, pkg, data, version, d, ud):
         pkgfullname = pkg
-        if version:
+        if version != '*' and not '/' in version:
             pkgfullname += "@%s" % version
         logger.debug(2, "Calling getdeps on %s" % pkg)
         fetchcmd = "npm view %s dist.tarball --registry %s" % (pkgfullname, ud.registry)
         output = runfetchcmd(fetchcmd, d, True)
         # npm may resolve multiple versions
         outputarray = output.strip().splitlines()
+        if not outputarray:
+            raise FetchError("The command '%s' returned no output" % fetchcmd)
         # we just take the latest version npm resolved
         #logger.debug(2, "Output URL is %s - %s - %s" % (ud.basepath, ud.basename, ud.localfile))
         outputurl = outputarray[len(outputarray)-1].rstrip()