Skip to contentSkip to conversation

recipetool npm fixes

PATCH New Paul Eggleton 1 participant 3 messages Apr 27, 2016

lore
Share & tools
lore
#0 lore raw

cover recipetool npm fixes

The following changes since commit e2dbe5eb869b8336b91023b83d7ca866197efa73:

license.bbclass: make sure that image manifest dir exists (2016-04-22 16:28:47 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib paule/recipetool-npm-fixes
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=paule/recipetool-npm-fixes

Paul Eggleton (2):
recipetool: create: fix picking up false npm package directories
recipetool: create: fix falling back to declared license for npm
packages

 meta/lib/oe/package.py               | 2 +-
 scripts/lib/recipetool/create.py     | 2 +-
 scripts/lib/recipetool/create_npm.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.5.5
#1 lore raw

PATCH 1/2 recipetool: create: fix picking up false npm package directories

It is possible for a Node.js module to have node_modules subdirectories that contain no package.json file (e.g. iotivity-node has such a directory). It appears these should simply be ignored, or else with the way the current code works we will get errors later.

---
 meta/lib/oe/package.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oe/package.py +1 -1
index 2887689..252e32d 100644
@@ -149,7 +149,7 @@ def npm_split_package_dirs(pkgdir):
                 if os.path.exists(pkgfile):
                     with open(pkgfile, 'r') as f:
                         data = json.loads(f.read())
-                packages[pkgname] = (relpth, data)
+                    packages[pkgname] = (relpth, data)
     # We want the main package for a module sorted *after* its subpackages
     # (so that it doesn't otherwise steal the files for the subpackage), so
     # this is a cheap way to do that whilst still having an otherwise
Signature · 1 line
2.5.5
#2 lore raw

PATCH 2/2 recipetool: create: fix falling back to declared license for npm packages

In reply to Paul Eggleton

Fix two problems falling back to the "license" field from package.json when no license file is present:
1) The function that was supposed to return the license field value was always explicitly returning None, and this was never noticed (because the test cases never exercised the fallback as they provided license files for each module).
2) Fix the main package not falling back because it had a default of an empty list, which evaluates to '' instead of 'Unknown'.

---
 scripts/lib/recipetool/create.py     | 2 +-
 scripts/lib/recipetool/create_npm.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
scripts/lib/recipetool/create.py +1 -1
index bb9fb9b..aade40b 100644
@@ -854,7 +854,7 @@ def split_pkg_licenses(licvalues, packages, outlines, fallback_licenses=None, pn
             pkglicenses[pn].append(license)
     outlicenses = {}
     for pkgname in packages:
-        license = ' '.join(list(set(pkglicenses.get(pkgname, ['Unknown']))))
+        license = ' '.join(list(set(pkglicenses.get(pkgname, ['Unknown'])))) or 'Unknown'
         if license == 'Unknown' and pkgname in fallback_licenses:
             license = fallback_licenses[pkgname]
         outlines.append('LICENSE_%s = "%s"' % (pkgname, license))
scripts/lib/recipetool/create_npm.py +1 -1
index b3ffcdb..cc4fb42 100644
@@ -45,7 +45,7 @@ class NpmRecipeHandler(RecipeHandler):
             license = data['license']
             if isinstance(license, dict):
                 license = license.get('type', None)
-        return None
+        return license
 
     def _shrinkwrap(self, srctree, localfilesdir, extravalues, lines_before):
         try:
Signature · 1 line
2.5.5