diff options
-rw-r--r-- | bitbake/lib/bb/fetch2/npm.py | 10 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/npmsw.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/tests/fetch.py | 2 |
3 files changed, 9 insertions, 5 deletions
diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py index b3a3a444ee..8f7c10ac9b 100644 --- a/bitbake/lib/bb/fetch2/npm.py +++ b/bitbake/lib/bb/fetch2/npm.py | |||
@@ -52,9 +52,13 @@ def npm_filename(package, version): | |||
52 | """Get the filename of a npm package""" | 52 | """Get the filename of a npm package""" |
53 | return npm_package(package) + "-" + version + ".tgz" | 53 | return npm_package(package) + "-" + version + ".tgz" |
54 | 54 | ||
55 | def npm_localfile(package, version): | 55 | def npm_localfile(package, version=None): |
56 | """Get the local filename of a npm package""" | 56 | """Get the local filename of a npm package""" |
57 | return os.path.join("npm2", npm_filename(package, version)) | 57 | if version is not None: |
58 | filename = npm_filename(package, version) | ||
59 | else: | ||
60 | filename = package | ||
61 | return os.path.join("npm2", filename) | ||
58 | 62 | ||
59 | def npm_integrity(integrity): | 63 | def npm_integrity(integrity): |
60 | """ | 64 | """ |
@@ -157,7 +161,7 @@ class Npm(FetchMethod): | |||
157 | # Using the 'downloadfilename' parameter as local filename | 161 | # Using the 'downloadfilename' parameter as local filename |
158 | # or the npm package name. | 162 | # or the npm package name. |
159 | if "downloadfilename" in ud.parm: | 163 | if "downloadfilename" in ud.parm: |
160 | ud.localfile = d.expand(ud.parm["downloadfilename"]) | 164 | ud.localfile = npm_localfile(d.expand(ud.parm["downloadfilename"])) |
161 | else: | 165 | else: |
162 | ud.localfile = npm_localfile(ud.package, ud.version) | 166 | ud.localfile = npm_localfile(ud.package, ud.version) |
163 | 167 | ||
diff --git a/bitbake/lib/bb/fetch2/npmsw.py b/bitbake/lib/bb/fetch2/npmsw.py index 879ba5de0f..a8c4d3528f 100644 --- a/bitbake/lib/bb/fetch2/npmsw.py +++ b/bitbake/lib/bb/fetch2/npmsw.py | |||
@@ -117,7 +117,7 @@ class NpmShrinkWrap(FetchMethod): | |||
117 | 117 | ||
118 | # Handle http tarball sources | 118 | # Handle http tarball sources |
119 | elif version.startswith("http") and integrity: | 119 | elif version.startswith("http") and integrity: |
120 | localfile = os.path.join("npm2", os.path.basename(version)) | 120 | localfile = npm_localfile(os.path.basename(version)) |
121 | 121 | ||
122 | uri = URI(version) | 122 | uri = URI(version) |
123 | uri.params["downloadfilename"] = localfile | 123 | uri.params["downloadfilename"] = localfile |
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py index 8b13e178e6..3fd8fac229 100644 --- a/bitbake/lib/bb/tests/fetch.py +++ b/bitbake/lib/bb/tests/fetch.py | |||
@@ -2399,7 +2399,7 @@ class NPMTest(FetcherTest): | |||
2399 | url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0;destsuffix=foo/bar;downloadfilename=foo-bar.tgz' | 2399 | url = 'npm://registry.npmjs.org;package=@savoirfairelinux/node-server-example;version=1.0.0;destsuffix=foo/bar;downloadfilename=foo-bar.tgz' |
2400 | fetcher = bb.fetch.Fetch([url], self.d) | 2400 | fetcher = bb.fetch.Fetch([url], self.d) |
2401 | fetcher.download() | 2401 | fetcher.download() |
2402 | self.assertTrue(os.path.exists(os.path.join(self.dldir, 'foo-bar.tgz'))) | 2402 | self.assertTrue(os.path.exists(os.path.join(self.dldir, 'npm2', 'foo-bar.tgz'))) |
2403 | fetcher.unpack(self.unpackdir) | 2403 | fetcher.unpack(self.unpackdir) |
2404 | unpackdir = os.path.join(self.unpackdir, 'foo', 'bar') | 2404 | unpackdir = os.path.join(self.unpackdir, 'foo', 'bar') |
2405 | self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json'))) | 2405 | self.assertTrue(os.path.exists(os.path.join(unpackdir, 'package.json'))) |